ios7 – 删除MFMailComposeViewController的UINavigationBar的半透明效果

前端之家收集整理的这篇文章主要介绍了ios7 – 删除MFMailComposeViewController的UINavigationBar的半透明效果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我没有找到去除MFMailComposeViewController的UINavigationBar的半透明效果(iOS 7)的方法.在我的应用程序中的所有其他UINavigationBars没有问题.

我没有成功尝试过:

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
mailController.navigationBar.translucent = NO;

任何想法 ?

解决方法

有点迟了,但是对于谁遇到这个帖子:

默认情况下,MFMailComposeViewController的导航栏将是半透明的,您无法更改.您可以更改的唯一属性是外观代理支持属性.从苹果文档:

The view hierarchy of this class is private and you must not modify
it. You can,however,customize the appearance of an instance by using
the UIAppearance protocol.

这会让您有限的选项来更改您的MFMailComposeViewController的导航栏外观,因为并不是所有的属性都被支持(例如,如果你尝试像[UINavigationBar外观] setTranslucent:NO];它会崩溃,因为该属性不被代理支持.

以下是Appearance代理支持属性列表:https://gist.github.com/mattt/5135521

现在,要将MFMailComposeViewController的导航栏设置为非半透明,您需要更改其backgroundColor(它是一个UIView允许的属性,UINavigationBar是UIView的子类):

[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];

在您实例化MFMailComposeViewController之前,请确保执行此操作,例如:

[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];

您也可以使用外观WConContainedIn:MFMailComposeViewController,仅当它由MFMailComposeViewController拥有时影响navBar,或者您可以选择将其更改回任何以前在mailComposeController中执行的操作:didFinishWithResult.

原文链接:https://www.f2er.com/iOS/335472.html

猜你在找的iOS相关文章