ios UITableView修改右側滾動條的顏色
阿新 • • 發佈:2019-02-09
系統的方法 只有幾種顏色
typedef NS_ENUM(NSInteger, UIScrollViewIndicatorStyle) { UIScrollViewIndicatorStyleDefault, // black with white border. good against any background UIScrollViewIndicatorStyleBlack, // black only. smaller. good against a white background UIScrollViewIndicatorStyleWhite // white only. smaller. good against a black background };
使用方法如下
self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
當需要自定義顏色的時候需要遍歷view 對子view的UIImageView進行設定
看reveal看出
在UITableViewController .m
重寫- (void)viewDidLayoutSubviews { //設定滾動條的顏色 for (UIView* subview in [self.view subviews]) { if([subview isKindOfClass:[UIImageView class]]) { UIImageView *img=(UIImageView*)subview; img.image=[UIImage imageNamed:@"huadongtiao"]; } } [super viewDidLayoutSubviews]; }