ios - 将 modalPresentationStyle 设置为自定义会导致 MFMailComposeViewController 中的状态栏颜色错误

标签 ios objective-c uiviewcontroller

我有一个简单的 Controller ,它显示另一个具有自定义转换的 Controller 。我使用实心导航栏:

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

这是第二个 Controller : enter image description here

当我在子 Controller 中打开 MFMailComposeViewController 时,状态栏是白色的(这也适用于 UIActivityViewController): enter image description here

原来这与设置modalPresentationStyleUIModalPresentationCustom有关:

- (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 中的状态栏类型?这可能是一个错误吗?

完整代码在这里https://github.com/mbigatti/StatusBarTest

最佳答案

也许你可以尝试添加:

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/

相关文章:

ios - Swift:将 "Back"作为默认按钮文本设置为 "segue back"按钮

ios - 执行时“else”语句未在 'didSelectRowAt' 函数中运行

iphone - 在摇动手势上做 IBAction

ios - 发生 NSNotification 时如何更改 UILabel 属性

ios - "Unrecognized selector sent to instance"用于扩展实现 TableView 的下拉刷新

ios - Xcode - 从 UIImageView 到新的 ViewController

ios - 无法从 UICollectionViewCell 中删除图像

ios - 最终使用 PFFile(解析本地数据存储)保存在 PFObject 上?

iOS延迟我无法弄清楚使用AVFoundation扫描条形码

iphone - 从 NSURLRequest 返回一个字符串