Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
730 views
in Technique[技术] by (71.8m points)

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;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...