美文网首页iOS Developer
iOS状态栏显示与隐藏

iOS状态栏显示与隐藏

作者: im小码哥 | 来源:发表于2017-03-15 10:49 被阅读67次

    在iOS 7.0及其以后版本中,iOS状态栏的显示和隐藏 还有状态栏的颜色修改方式如下:

    (1) 整个app隐藏

    在项目的info.plist文件中加入

    View controller-based status bar appearance-NO

    Status bar is initially hidden-YES

    如图:

    (2) 单个页面修改

    只需要加入Status bar is initially hidden-YES 即可,然后在需要隐藏/显示的地方加上代码

    - (BOOL)prefersStatusBarHidden {

    returnYES;//YES表示隐藏,NO表示显示。

    }

    然后状态栏的颜色设置加上如下代码,根据需求而定

    - (UIStatusBarStyle)preferredStatusBarStyle{

    return UIStatusBarStyleDefault;

    //UIStatusBarStyleDefault = 0 黑色文字,浅色背景时使用

    //UIStatusBarStyleLightContent = 1 白色文字,深色背景时使用

    }

    相关文章

      网友评论

        本文标题:iOS状态栏显示与隐藏

        本文链接:https://www.haomeiwen.com/subject/bthlnttx.html