现在的位置: 首页 > 综合 > 正文

ios 7 statusbar跟随navigationbar的颜色而改变

2014年08月29日 ⁄ 综合 ⁄ 共 942字 ⁄ 字号 评论关闭


在此输入图片描述

首先,我们要搞清楚info.plist中 View 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:

1
[[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];

转子oschina

抱歉!评论已关闭.