User1075
User1075

Reputation: 885

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?

enter image description here

Upvotes: 2

Views: 1593

Answers (2)

Dharmesh Dhorajiya
Dharmesh Dhorajiya

Reputation: 3984

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];
}

Upvotes: 3

Devos50
Devos50

Reputation: 2035

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.

Upvotes: 1

Related Questions