preferredStatusBarStyle不起作用

2019-05-07  本文已影响0人  姬歌

设置statusbarStyle不起作用

如果要每个页面自定义style,需要在info.list中设置View controller-based status bar appearance = YES

然后在每个viewController中设置(可在基类中也统一设置,需要改变style的时候重写覆盖)

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;//or UIStatusBarStyleLightContent
}

但是,\color{red}{不起作用啊!!!!}
原因是你的viewController嵌在NavigationController中!\color{red}{还需要在NavigatioinController基类中设置}

- (UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

- (UIViewController *)childViewControllerForStatusBarHidden {
    return self.topViewController;
}

才行!

上一篇 下一篇

猜你喜欢

热点阅读