改变navigationbar的底部线条颜色

[[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

原文地址:https://www.cnblogs.com/huoran1120/p/5712010.html