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

2018-08-07  本文已影响7人  zanyzephyr

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
    }
上一篇下一篇

猜你喜欢

热点阅读