日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

View controller-based status bar

發布時間:2023/12/9 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 View controller-based status bar 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
    • info.plist文件中,View controller-based status bar appearance項設為YES,則View controller對status bar的設置優先級高于application的設置。為NO則以application的設置為準,view controller的prefersStatusBarHidden方法無效,是根本不會被調用的。


      一、如果View controller-based status bar appearance 設為YES。

      這時 view controller中對status bar的設置優先級高于application的設置,用下面的方式隱藏status bar:


      1、在view controller中調用setNeedsStatusBarAppearanceUpdate,更新status bar的顯示。

      - (void)viewDidAppear:(BOOL)animated

      {

      [super viewDidAppear:animated];

      if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {

      [self prefersStatusBarHidden];

      [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];

      }

      }


      2、覆蓋view controller的prefersStatusBarHidden的實現,返會YES。

      - (BOOL)prefersStatusBarHidden

      {

      return YES;

      }


      二、如果View controller-based status bar appearance 設為NO,這時application的設置優先級最高,用下面的方式隱藏status bar:

      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];


      綜合上面的結論,如果iOS6和iOS7都支持,則處理方式如下:

      一、如果View controller-based status bar appearance 設為NO。

      則在iOS6和iOS7都是用下面的方法隱藏status bar。

      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];


      二、如果View controller-based status bar appearance 設為YES。

      則需要判斷當前是iOS6還是iOS7。如果是iOS6,則還通過sharedApplication隱藏。

      如果是iOS7,則用setNeedsStatusBarAppearanceUpdate加prefersStatusBarHidden的方式來隱藏 status bar。



      取info.plist中 View controller-based status bar appearance中的設置:

      NSNumber *isVCBasedStatusBarAppearanceNum = [[NSBundle mainBundle]objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];

      if (isVCBasedStatusBarAppearanceNum) {

      _isVCBasedStatusBarAppearance = isVCBasedStatusBarAppearanceNum.boolValue;

      } else {

      _isVCBasedStatusBarAppearance = YES; // default

      }

轉載于:https://www.cnblogs.com/lee4519/p/4195203.html

總結

以上是生活随笔為你收集整理的View controller-based status bar的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。