ios 7 statusbar 狀態欄 跟隨navigationbar的顏色而改變

在此輸入圖片描述

首先,咱們要搞清楚info.plist中 View controller-based status bar appearance這個屬性 View controller-based status bar appearance =NO 這個設置爲:View Controller 不對status Bar 顯示進行操做app

而後在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:code

[[UINavigationBar appearance] setBarTintColor:myColor];

這樣就搞定了,哈哈圖片

這裏還能夠特定容器類的選項: 官方定義: To customize the appearances for instances of a class contained within an instance of a container class:it

[[UINavigationBar appearanceWhenContainedIn:[UISplitViewController class], nil] setBarTintColor:myColor]; [[UINavigationBar appearanceWhenContainedIn:[UITabBarController class], [UISplitViewController class], nil] setBarTintColor:myTabbedNavBarColor];io

相關文章
相關標籤/搜索