MFMailComposeViewController在iOS 7中忽略了部分UIAppearance协议。

7
我有一个仅支持iOS 7的应用程序,使用UIAppearance为整个应用程序中的UINavigationBar设置样式。
我在AppDelegate中有以下代码:
[[UINavigationBar appearance] setBackgroundImage:redImage forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];

然而,MFMailComposeViewController出现了红色背景的图像!

文档中说:

重要提示:此类的视图层次结构是私有的,您不能修改它。但是,您可以使用UIAppearance协议自定义实例的外观。

所以以上操作不应该有问题,我100%确定redImageblueImage是不同颜色的图片。

还有其他人遇到过这个问题吗? 我猜这是iOS 7的一个bug,但我还没有时间在iOS 6上进行检查(我是通过iPad 4来获取这些结果的)。


在显示composer之前,你是否尝试过设置外观? - Leszek Zarna
@LeszekŻarna 是的,绕过它的一个技巧是在我展示它之前设置全局外观,然后在我解除它之前将其改回来。但是这似乎不切实际,我想知道是否有一个正确的解决方法。 - liamnichols
@LeszekŻarna 你遇到类似的问题了吗?我卡住了。https://dev59.com/DnrZa4cB1Zd3GeqP4p6H - Sam B
1个回答

2
您可以直接在MFMailComposeViewController上设置外观。
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[MFMailComposeViewController.navigationBar setBackgroundImage:blueImage forBarMetrics:UIBarMetricsDefault];

不再了,至少现在不是。 - pronebird

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接