1

Can you please suggest me, what is the proper way to setup the style of statusbar for MFMailComposeViewController in iOS >= 9.0? I know, that [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; is deprecated and I can't use it. I know that the possible solution is adding category like this:

#import "MFMailComposeViewController+StatusBarStyle.h"
@implementation MFMailComposeViewController (StatusBarStyle)
#pragma mark - Status bar management
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (UIViewController *)childViewControllerForStatusBarStyle {
    return nil;
}
@end

But in this case I should enable View controller-based status bar appearance option and implement - (UIStatusBarStyle)preferredStatusBarStyle in the all ViewContollers that exist in my app (and I have a lot of them). So, is there another solution?

Sergei Belous
  • 4,708
  • 1
  • 16
  • 20

2 Answers2

0

Okay, I created my own CommonNavigationViewController, added these two methods:

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (UIViewController *)childViewControllerForStatusBarStyle {
    return nil;
}

And changed the class of Root Navigation Controller in Storyboard to this one. It helps and now the all VCs that appears in Navigation Controller's stack have the Light Status bar. But anyway, I don't like this solution :(

Sergei Belous
  • 4,708
  • 1
  • 16
  • 20
-1
(UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

Add this to yourviewcontroller.m file.

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42
  • Welcome to Stack Overflow! Please don't answer just with source code. Try to provide a nice description about how your solution works. See: [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Thanks – sɐunıɔןɐqɐp Oct 01 '18 at 07:50