Xcode Hide white status bar ios 10

前端 未结 5 2052
感情败类
感情败类 2021-01-18 03:26

I want white status bar in my app. For this I set View controller-based status bar appearance to NO and Status bar style to UISt

5条回答
  •  借酒劲吻你
    2021-01-18 03:57

    In your plist file add View controller-based status bar appearance Bool property and set it to YES.

    Now in your view controller add the methods like below:

    // TO MAKE STATUS BAR WHITE
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
            return .LightContent
    }
    
    // TO MAKE STATUS BAR BLACK
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
            return .LightContent
    }
    
    // RETURN TRUE TO HIDE AND FALSE TO SHOW STATUS BAR
    override func prefersStatusBarHidden() -> Bool {
            return true
    }
    

    For Objective-C

    - (BOOL)prefersStatusBarHidden {
        return NO;
    }
    
    -(UIStatusBarStyle)preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    

    For removing redundant code you can make a BaseViewController as subclass of UIViewController and add the methods in that class. And override the method in the class which requires change.

提交回复
热议问题