给NavigationBar设置颜色

  传统的设置

if (IOSVERSION >= 7) {

     [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];

} else {

     [[UINavigationBar appearance] setBarTintColor:[UIColor redColor]]
]; }

  在ios6下显示正常,但是在ios7下颜色却看起来有点失真!!!

     那是因为ios坑爹的加了translucent属性也就是半透明,我可以很负责人的说,你怎么设置都不起效,坑爹的模糊效果.

  正确的姿势:

[[UINavigationBar appearance] setBackgroundImage:[UIColor redColor] forBarMetrics:UIBarMetricsDefault];

   简单的功能更见基础的重要!

原文地址:https://www.cnblogs.com/mohe/p/4226393.html