Info.plist

设置电池条颜色 - (UIStatusBarStyle)pref

2022-07-26  本文已影响0人  失忆的程序员

方法一

info中+
View controller-based status bar appearance
设置为yes
YES

在你用到的VC中添加下面copy进你的VC中、

OC
- (UIStatusBarStyle)preferredStatusBarStyle {
    if (@available(iOS 13.0, *)) {
        return UIStatusBarStyleDarkContent;
    } else {
        // Fallback on earlier versions
        return UIStatusBarStyleLightContent;
    }
}
Swift

    override var preferredStatusBarStyle: UIStatusBarStyle {
      return .lightContent 
    }

方法二

    ⚠️'setStatusBarStyle:animated:' is deprecated: first deprecated in iOS 9.0 - Use -[UIViewController preferredStatusBarStyle]
//
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
  
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

上一篇下一篇

猜你喜欢

热点阅读