我有一个简单的 Controller ,它显示另一个具有自定义转换的 Controller 。我使用实心导航栏:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.barTintColor = [UIColor purpleColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
这是第二个 Controller :
当我在子 Controller 中打开 MFMailComposeViewController
时,状态栏是白色的(这也适用于 UIActivityViewController
):
原来这与设置modalPresentationStyle
为UIModalPresentationCustom
有关:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *controller = (UIViewController*)segue.destinationViewController;
// this line cause the bug
//controller.modalPresentationStyle = UIModalPresentationCustom;
controller.transitioningDelegate = self;
}
如果 controller.modalPresentationStyle
保持不变,状态栏颜色是正确的。此外,此属性似乎不会干扰自定义转换。
我在这里遗漏了什么?为什么 modalPresentationStyle
会影响系统 Controller 中的状态栏类型?这可能是一个错误吗?
最佳答案
也许你可以尝试添加:
controller.modalPresentationCapturesStatusBarAppearance = YES
在设置 modalPresentationStyle
之后。根据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.
关于ios - 将 modalPresentationStyle 设置为自定义会导致 MFMailComposeViewController 中的状态栏颜色错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24406275/