UIStatusBarStyle not working in Swift

前端 未结 11 585
轻奢々
轻奢々 2020-12-22 18:30

I\'m trying to change the Status Bar color in my Swift app to white, but am hitting a brick wall. I have 3 ViewControllers that are each embedded in a NavigationController (

11条回答
  •  梦毁少年i
    2020-12-22 19:27

    For iOS9.x and Xcode7, just put this inside AppDelegate.swift:

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    
        UINavigationBar.appearance().barStyle = .Black
    
    } 
    

    This will automatically turn your status bar's style to .Lightcontent for all the view controllers inside a UINavigationController.

    (Also, delete View controller-based status bar appearance from Info.plist to suppress the warnings you're probably seeing too!)

提交回复
热议问题