How to change UIStatusBarStyle in iOS 7 in modal views with navigation bar?

后端 未结 9 2413
孤独总比滥情好
孤独总比滥情好 2020-12-31 11:32

The iOS 7 Transition Guide give a good hint how to change the UIStatusBarStyle dynamically in a UIViewController using

- (UIStatus         


        
9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-31 11:47

    We should notice that non-fullscreen modalVC CAN use modalPresentationCapturesStatusBarAppearance to control the statusBar style.

    Anyone who wanna know more about Status Bar control should not ignore the UIViewController Managing the Status Bar.

    Update at 2015-11-06:

    And make sure you have set UIViewControllerBasedStatusBarAppearance described in iOS Keys

    Update at 2018.04.09:

    I noticed that viewController in a navController may not get call prefersStatusBarHidden with iOS 10.0 - 10.2. Custom your navigationController to ensure that

    @implementation YourCustomNavController
    //for iOS 10.0 - iOS 10.2
    - (BOOL)prefersStatusBarHidden {
        UIViewController *childVC = [self childViewControllerForStatusBarHidden];
        if (childVC) {
            return [childVC prefersStatusBarHidden];
        }
        return [super prefersStatusBarHidden];
    }
    @end
    

    And anyone who want to go deeper inside can dig into UIKit +[UIViewController _currentStatusBarStyleViewController] using Hopper or IDA Pro. It may helps you solve these kinds of bugs.

提交回复
热议问题