简体   繁体   中英

How to achieve this custom Scroll bar in IOS or something similar to it?

Actually I have a table view with options, but alongside I have a complicated scroll design. How could I go about implementing this scroller?

在此处输入图片说明

Create UISlider vertical

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self addSliderVertical];
}

-(void) addSliderVertical{
    slider=[[UISlider alloc]initWithFrame:CGRectMake(20, 40, 300, 300)];// set fram your require position 
    CGAffineTransform trans=CGAffineTransformMakeRotation(M_PI_2);
    slider.transform=trans;
    [self.view addSubview:slider];
    slider.minimumValue=1;
    slider.maximumValue=100;
    slider.continuous=NO;
    [slider addTarget:self action:@selector(sliderChanhge:) forControlEvents:UIControlEventValueChanged];
}

Slider change method

-(IBAction)sliderChanhge:(id)sender
{
    // here change tableview scroll offset
    [self.tableView setContentOffset:CGPointMake(0, (int)slider.value) animated: YES];
}

You could probably use a customized UISlider for this. When the value of the slider changes, you can adjust the scroll offset of the UITableView next to it.

I wonder whether it is really necessary for your design to use this kind of element since it is not very intuitive (at least on iOS) to use a custom scrollbar. When you really have to use the custom scrollbar, I would go with a customized version of an UISlider .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM