0

I want to move UIImageview along scrollbar in scrollview . I tried in DidScroll Delegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    static NSInteger previousPage = 0;
    NSLog(@"scrolliview= %f",scrollView.contentOffset.x);

   [_img_moving setBackgroundColor:[UIColor greenColor]];
    _img_moving.frame = CGRectMake(
                                 scrollView.contentOffset.x,
                                 0, 320/2, 10);

}

frame of uiimageview is not changing. Note: My aim is to make scrollbar of green color with width 10 px

zkn
  • 63
  • 1
  • 9

1 Answers1

0

Please try following code, change colours of vertical and horizontal scrollbar according to your need, for more detailed answers please follow this link:
ios Changing UIScrollView scrollbar color to different colors

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    //get refrence of vertical indicator
    UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]);
    //set color to vertical indicator
    [verticalIndicator setBackgroundColor:[UIColor greenColor]];


    //get refrence of horizontal indicator
    UIImageView *horizontalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-2)]);
    //set color to horizontal indicator
    [horizontalIndicator setBackgroundColor:[UIColor redColor]];
}
Community
  • 1
  • 1
Aamir
  • 16,329
  • 10
  • 59
  • 65
  • bro , I had tried that link already but got no succes , it just change the color of image nor move the image, I want to move the image like scrollbar – zkn Jan 08 '16 at 11:35