美文网首页
iOS中为指定的ViewController设置状态栏颜色

iOS中为指定的ViewController设置状态栏颜色

作者: zanyzephyr | 来源:发表于2018-08-07 19:16 被阅读7次

    0.环境

    swift 4、
    iOS 11

    1.第一步

    info.plist中,新添加一行View controller-based status bar appearance,值设置为NO

    2.第二步

    在指定的ViewController中,覆盖viewWillAppear方法,如下:

        override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
            
            UIApplication.shared.statusBarStyle = .lightContent
        }
    

    相关文章

      网友评论

          本文标题:iOS中为指定的ViewController设置状态栏颜色

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