有点晚了,但对于遇到这篇文章的人来说:
默认情况下,MFMailComposeViewController 的导航栏将是半透明的,您无法更改它。您可以更改的唯一属性是外观代理支持的属性。来自 Apple 文档:
这个类的视图层次是私有的,你不能修改它。但是,您可以使用 UIAppearance 协议自定义实例的外观。
这使您更改 MFMailComposeViewController 的导航栏外观的选项有限,因为并非所有属性都受支持(例如,如果您尝试类似 [UINavigationBar 外观] setTranslucent:NO]; 它会崩溃,因为代理不支持此属性.
这是外观代理支持的属性列表:https ://gist.github.com/mattt/5135521
现在,要将 MFMailComposeViewController 的 navigationBar 设置为非半透明,您需要更改它的 backgroundColor(它是 UIView 允许的属性,UINavigationBar 是 UIView 的子类):
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
确保在实例化 MFMailComposeViewController 之前执行此操作,例如:
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
您还可以使用外观当包含在:MFMailComposeViewController,仅当导航栏由 MFMailComposeViewController 拥有时才影响导航栏,或者您可以选择将其更改回 mailComposeController:didFinishWithResult 中的任何内容。