改变线条颜色
//设置导航栏底部线条颜色
UINavigationBar *navigationBar = self.navigationBar;
// [navigationBar setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault]; //此处使底部线条颜色为浅灰色
CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
UIColor *color = rgba(238, 238, 238, 1);
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[navigationBar setShadowImage:img];
网友评论