您的位置:首页 > 其它

改变navigationbar的底部线条颜色

2016-07-27 17:37 337 查看
[[UINavigationBar appearance] setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];

CGRect rect = CGRectMake(0.0f, 0.0f, ScreenWidth, 0.5);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, RGBCOLOR(230, 230, 230).CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[[UINavigationBar appearance]setShadowImage:image];

以上写在了appdelegate中,其他地方没有试

重点来了,一定要两个都设置才可以

setBackgroundImage

setShadowImage
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: