美文网首页Info.plist
设置电池条颜色 - (UIStatusBarStyle)pref

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

作者: 失忆的程序员 | 来源:发表于2022-07-26 11:36 被阅读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];
    
    

    相关文章

      网友评论

        本文标题:设置电池条颜色 - (UIStatusBarStyle)pref

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