zoukankan      html  css  js  c++  java
  • iOS7 status bar 样式问题

    在ios7中,有如下status bar 样式

    typedef NS_ENUM(NSInteger, UIStatusBarStyle) {
        UIStatusBarStyleDefault                                     = 0, // Dark content, for use on light backgrounds
        UIStatusBarStyleLightContent     NS_ENUM_AVAILABLE_IOS(7_0) = 1, // Light content, for use on dark backgrounds
        
        UIStatusBarStyleBlackTranslucent NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 1,
        UIStatusBarStyleBlackOpaque      NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 2,
    };

    其实,也就2种,一种是UIStatusBarStyleDefault,字体为黑色,另一种是UIStatusBarStyleLightContent字体为白色。

    当设置View controller-based status bar appearance为yes后,我们就可以通过- (UIStatusBarStyle)preferredStatusBarStyle来设置status bar样式了。

    但是有许多中需要考虑的情况。

    1.使用UITabBarController

    使用UITabBarController后,status bar样式会根据每个子controller的- (UIStatusBarStyle)preferredStatusBarStyle返回值来定,这也是符合常理的。UITabBarController中的- (UIStatusBarStyle)preferredStatusBarStyle不会被访问。

    2.使用UINavigationController

    UINavigationController和UITabBarController不同。使用UINavigationController后,status bar样式会根据UINavigationController的- (UIStatusBarStyle)preferredStatusBarStyle返回值来定,各个子controller的- (UIStatusBarStyle)preferredStatusBarStyle不会被访问。

    3.在UITabBarController中包含UINavigationController

    根据上面的2点,如果你需要在这种条件下更改status bar的样式,你需要更改的是每个UINavigationController的- (UIStatusBarStyle)preferredStatusBarStyle方法。

    先写到这里,待续。。。

  • 相关阅读:
    [Android应用开发] 01.快速入门
    [wordpress使用]004_导入多媒体
    【Python3爬虫】使用异步协程编写爬虫
    【Python3爬虫】斗鱼弹幕爬虫
    Pycharm2018永久破解的办法
    【Python3爬虫】大众点评爬虫(破解CSS反爬)
    【Python3爬虫】用Python发送天气预报邮件
    【Python3爬虫】猫眼电影爬虫(破解字符集反爬)
    【Python3爬虫】微博用户爬虫
    【Python3爬虫】拉勾网爬虫
  • 原文地址:https://www.cnblogs.com/breezemist/p/3727902.html
Copyright © 2011-2022 走看看