iOS 7: modal view controller status bar is wrong color but normal view controllers are correct

前端 未结 9 1355
慢半拍i
慢半拍i 2021-02-05 06:20

I have an issue in iOS7 where a normal UINavigationController pushed view controller has the correct status bar text color for the UINavigationController navbar color (which is

相关标签:
9条回答
  • 2021-02-05 07:08

    set YourModalViewControler.modalPresentationCapturesStatusBarAppearance to YES and keep "View controller-based status bar appearance" to YES.

    - (void)viewDidLoad {
        [super viewDidLoad];
        self.modalPresentationCapturesStatusBarAppearance = YES;
        ....
    }
    

    then overwrite preferredStatusBarStyle

    - (UIStatusBarStyle)preferredStatusBarStyle {
        return TheStyleYouWant;
    }
    
    0 讨论(0)
  • 2021-02-05 07:10

    My solution:

    newViewController.modalPresentationStyle = .fullScreen
    

    By default, UINavigationController decides the status bar style and overrides all sub view controllers styles. However, when a modal view controller is fullscreen, its method preferredStatusBarStyle is called.

    0 讨论(0)
  • 2021-02-05 07:13

    Set UIViewControllerBasedStatusBarAppearance to NO in your info.plist

    0 讨论(0)
提交回复
热议问题