IOS7状态栏【statusbar】与导航栏【navigationbar】同步颜色2015-04-13 11:20:44
首先,我们要搞清楚info.plist中 controller-based status bar appearance这个属性
View controller-based status bar appearance =NO
这个设置为:View Controller 不对status Bar 显示进行操作
然后在viewcontroller里面修改navigationbar的颜色
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:65/255.0 green:159/255.0 blue:252/255.0 alpha:0.5]];
官方给出的意思
To customize the appearance of all instances of a class, send the relevant appearance modification messages to the appearance proxy for the class.(自定义的一个类的所有实例的外观,发送相关信息到外观的外观的代理类)For example, to modify the bar tint color for all UINavigationBar instances:
[[UINavigationBar appearance] setBarTintColor:myColor];
这样就可以了
这里还可以特定容器类的选项:
下面见官方定义:
To customize the appearances for instances of a class contained within an instance of a container class:
[[UINavigationBar appearanceWhenContainedIn:[UISplitViewController class], nil] setBarTintColor:myColor];
[[UINavigationBar appearanceWhenContainedIn:[UITabBarController class], [UISplitViewController class], nil] setBarTintColor:myTabbedNavBarColor];