亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ios7中UIViewControllerBasedStatusBarAppearance作用詳解

 更新時(shí)間:2016年11月10日 17:15:20   作者:skyYangpan  
這篇文章主要介紹了 ios7中UIViewControllerBasedStatusBarAppearance作用詳解的相關(guān)資料,需要的朋友可以參考下

  ios7中UIViewControllerBasedStatusBarAppearance詳解

在作iOS7的適配時(shí),很多文章都會(huì)提到UIViewControllerBasedStatusBarAppearance。便一直不是太明白其實(shí)際作用,使用時(shí)發(fā)現(xiàn)UIViewControllerBasedStatusBarAppearance的實(shí)際作用如下:      

這個(gè)屬性只影響如何設(shè)置status bar上字體的顏色是暗色(黑色)還是亮色(白色),對(duì)status bar的背景色無影響。status bar的背景色在iOS7上永遠(yuǎn)是透明的。

apple官方對(duì)UIViewControllerBasedStatusBarAppearance得說明:

UIViewControllerBasedStatusBarAppearance (Boolean - iOS) specifies whether the status bar appearance is based on the style preferred by the view controller that is currently under the status bar. When this key is not present or its value is set to YES, the view controller determines the status bar style. When the key is set to NO, view controllers (or the app) must each set the status bar style explicitly using the UIApplication object.

即:UIViewControllerBasedStatusBarAppearance(一個(gè)Boolean值)指定狀態(tài)欄的外觀是否是基于當(dāng)前視圖控制器給狀態(tài)欄指定的首選風(fēng)格。當(dāng)這個(gè)鍵不存在,或者它的值設(shè)置為YES時(shí)(也就是說這個(gè)key的默認(rèn)value為yes),視圖控制器決定了狀態(tài)欄的風(fēng)格。當(dāng)按鍵被設(shè)置為NO,視圖控制器(或應(yīng)用程序)都必須通過UIApplication對(duì)象(即UIApplication的setStatusBarStyle方法)顯示的設(shè)置狀態(tài)欄風(fēng)格。

通過apple的官方文檔不難看出,在ios7上,設(shè)置狀態(tài)欄風(fēng)格(暗色或者亮色)的方法無非就兩種,第一種是在controller中通過回調(diào)方法preferredStatusBarStyle返回狀態(tài)欄的風(fēng)格,第二種是通過UIApplication對(duì)象的setStatusBarStyle設(shè)置, UIViewControllerBasedStatusBarAppearance實(shí)際上是指定了是否優(yōu)先使用第一種方法(這也就不難理解為什么這個(gè)key值叫做UIViewControlle “based”)。

所以當(dāng)plist中沒有UIViewControllerBasedStatusBarAppearance這個(gè)key,或者存在這個(gè)key,并且value為YES時(shí),
viewController的preferredStatusBarStyle方法對(duì)狀態(tài)欄的設(shè)置生效;

當(dāng)UIViewControllerBasedStatusBarAppearance對(duì)應(yīng)的value為NO時(shí),
[UIApplication sharedApplication] 通過方法setStatusBarStyle對(duì)狀態(tài)欄的設(shè)置生效。

隱藏狀態(tài)欄

有時(shí)候我們需要隱藏狀態(tài)欄,那么此時(shí)我們?cè)趘iew controller中override方法prefersStatusBarHidden:即可,如下代碼所示:

- (BOOL)prefersStatusBarHidden 
{ 
  return YES; 
} 

 感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論