Change width and colour of scroll bar in UITableView, iphone
I could only find if one wants to display scroll bar or not using
tableView.showsVerticalScrollIndicator = YES/NO;
but how can I customize the scroll bar for colour, width and if possible other features?
Any help will be greatly appreciated.
EDIT:
I got this idea from code snippets where one must find Google logo in MKMapKit and relocate it somewhere so that it remains visible. by following method one can set custom image to scroll bar of UItbaleview. But I found nothing on changing size of scroll bar.
-(void) ViewDidLoad
{
UIImageView *testView = [self.tableView.subviews objectAtIndex:1];
UIImage *Img = [UIImage imageNamed:@"image.png"];
[testView setImage:Img];
}
EDIT: As suggested by Nekto you can use following to change width.
CGRect frame = testView.frame;
frame.size.width = 10; //set any value you want.
testView.frame = frame;
Solution 1:
You can set only style of scroll indicators:
The style of the scroll indicators.
@property(nonatomic) UIScrollViewIndicatorStyle indicatorStyle
Styles:
Scroll Indicator Style The style of the scroll indicators. You use these constants to set the value of the indicatorStyle style.
typedef enum {
UIScrollViewIndicatorStyleDefault,
UIScrollViewIndicatorStyleBlack,
UIScrollViewIndicatorStyleWhite
} UIScrollViewIndicatorStyle;
For example:
tableView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
Solution 2:
You can change the scroll indicator color using:
tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
Hope this helps.
Solution 3:
You can add this great open source custom scrollbar to your project, its totally customisable: https://github.com/BasheerSience/BRScrollBar
Solution 4:
You can hide the original scroll bar and scroll using your custom scroll bar.
– (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
can be used to scroll content, just add your custom bar to the table.