PreferredStatusBarStyle for native controllers
Since apple introduced UIViewControllerBasedStatusBarAppearance
and preferredStatusBarStyle
in iOS 7, I try to understand that it is best to change the status bar color for the built-in type controller, for example:
UIImagePickerController
MFMailComposeViewController
UISearchDisplayController
for example, on use, UISearchDisplayController
I want to change the status bar from light to dark when the search bar appears.
How should I do it? do i need a subclass UISearchDisplayController
? maybe a category?
and as far UIImagePickerController
as it has its own stack of view controllers, how to change the style of the status bar for all of them when the photo picker is presented?
so far i have used the global cause
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
but now its approach to per-ViewController, so how can I change controllers that are not mine?
source to share
Yes, you can subclass these classes to change the appearance of the status bar. As per UIImagePickerController
it's just a subclass UINavigationController
, so if you subclass and implement preferredStatusBarStyle
in your subclass, all other views displayed in the navigation will have the same status bar. Good luck!
source to share