UISearchController changing status bar color on invocation

后端 未结 6 1583
执念已碎
执念已碎 2021-02-08 18:09

I have the following code in my app, specifically in viewDidLoad: that sets up my UISearchController.

self.searchController = [[UISear         


        
6条回答
  •  旧时难觅i
    2021-02-08 18:19

    As of iOS 10 (maybe earlier?), if you have "View controller-based status bar appearance" set to YES in your Info.plist, simply set the preferredStatusBarStyle in the UIViewController that the UISearchController is included in.

    - (UIStatusBarStyle)preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    

    (you don't need to subclass or create a category/extension of UISearchController to override preferredStatusBarStyle... it uses the preferredStatusBarStyle that you set in your UIViewController)

提交回复
热议问题