Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting modalPresentationStyle to custom causes wrong status bar color in MFMailComposeViewController

I've a simple controller that shows another controller with a custom transition. I use a solid navigation bar:

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.barTintColor = [UIColor purpleColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

This is the second controller: enter image description here

When I open a MFMailComposeViewController in the child controller, the status bar is white on white (this appens also with UIActivityViewController): enter image description here

It turns out that this is related to setting modalPresentationStyle to UIModalPresentationCustom:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UIViewController *controller = (UIViewController*)segue.destinationViewController;

    // this line cause the bug
    //controller.modalPresentationStyle = UIModalPresentationCustom;

    controller.transitioningDelegate = self;
}

The status bar color is correct if controller.modalPresentationStyle is left unchanged. Moreover, this property seems not to interfere with the custom transition.

I'm missing something here? Why modalPresentationStyle impacts on the status bar type in system controllers? Could this be a bug?

Full code is here https://github.com/mbigatti/StatusBarTest

like image 798
mxb Avatar asked Jun 25 '14 10:06

mxb


1 Answers

Maybe you could try adding:

controller.modalPresentationCapturesStatusBarAppearance = YES

after setting the modalPresentationStyle. According to the UIViewController class reference:

When you present a view controller by calling the presentViewController:animated:completion: method, status bar appearance control is transferred from the presenting to the presented view controller only if the presented controller’s modalPresentationStyle value is UIModalPresentationFullScreen. By setting this property to YES, you specify the presented view controller controls status bar appearance, even though presented non–fullscreen.

like image 90
spassas Avatar answered Sep 19 '22 21:09

spassas