Make vertical scrollbar always visible in UIScrollView

Download : https://github.com/jaredsinclair/JTSScrollIndicator

JTSScrollIndicator.m

Add the following statements in the method initWithScrollView:

  • [_scrollView setShowsHorizontalScrollIndicator:NO];
  • [_scrollView setShowsVerticalScrollIndicator:NO];

Comment all the statements in the method hide:

JTSScrollIndicator.h

Added the following method declarations

  • – (void)show:(BOOL)animated;
  • + (BOOL)indicatorShouldBeVisibleForScrollView:(UIScrollView *)scrollView;

ViewController.h

#import “JTSScrollIndicator.h”
@property (strong, nonatomic) JTSScrollIndicator *indicator;

ViewController.m

- (void)viewDidLoad {
[super viewDidLoad];
self.indicator = [[JTSScrollIndicator alloc] initWithScrollView:scrollview];
self.indicator.backgroundColor = [UIColor colorWithRed:5.0/255.0 green:127.0/255.0 blue:231.0/255.0 alpha:1.0];
}

- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
scrollview.contentOffset = CGPointMake(0.0, 1.0);
[self.indicator show:YES];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.indicator scrollViewDidScroll:scrollView];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
[self.indicator scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self.indicator scrollViewDidEndDecelerating:scrollView];
}

- (void)scrollViewWillScrollToTop:(UIScrollView *)scrollView {
[self.indicator scrollViewWillScrollToTop:scrollView];
}

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
[self.indicator scrollViewDidScrollToTop:scrollView];
}

Advertisements

One Response to “Make vertical scrollbar always visible in UIScrollView”

  1. Aditya sengar Says:

    I need in swift


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: