appearanceWhenContainedIn

appearanceWhenContainedIn

本文介绍了MFMessageComposeViewController外观iOS 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外观代理,将 barTintColor 属性设置为绿色 UINavigationBar

I have an appearance proxy that sets the barTintColor property to green on UINavigationBar

[[UINavigationBar外观] setBarTintColor:[UIColor colorWithRed:54。/ 255绿色:165。/ 255蓝色:53。/ 255 alpha:1]];

根据需要,我使用 appearanceWhenContainedIn:

[[UINavigationBar appearanceWhenContainedIn:[INFSearchViewController class],nil] setBarTintColor:[UIColor colorWithWhite:0.80 alpha:1]];

这很好用。

然而,当我提出 MFMessageComposeViewController 时,它会遵守 UINavigationBar 代理,如下所示。

However when I present an MFMessageComposeViewController it adheres to the UINavigationBar proxy and looks like the following.

这显然看起来很糟糕,我宁愿 MFMessageComposeViewController 不遵守代理但试图执行

Which obviously looks terrible, I would prefer MFMessageComposeViewController to not adhere to the proxy but attempting to do

[[UINavigationBar appearanceWhenContainedIn:[MFMessageComposeViewController class],nil] setBarTintColor:[UIColor whiteColor]];

没有影响。

我应该采取什么行动?

What course of action should I take here?

推荐答案

hacky方式:将外观设置回默认白色,显示模态,将模态设置为样式返回。

The hacky way: set the appearance back to the default white, present the modal, set the appearance to styled when the modal returns.

或者,改变你的想法。将全局外观保留为默认值。然后你可以选择适当地应用样式化的导航栏。

Or, reverse your thinking. Leave the global appearance as the default. Then you can selectively apply the styled nav bar where appropriate.

如果在适当的地方最终成为应用程序的90%,只需设置一个瘦的UIViewController子类(或者你使用的任何视图控制器)以及你想要外观的那个。

If "where appropriate" ends up being 90% of the app, just set up a thin subclass of UIViewController (or whatever view controller you use a lot) and that use that where you want the appearance.

[[UINavigationBar appearanceWhenContainedIn:[MyStyledViewController class], nil]
  setBarTintColor:[UIColor colorWithRed:54./255 green:165./255 blue:53./255 alpha:1]];

在每个.h文件中,将视图控制器超类设置为 MyStyledViewController 而不是普通的旧 UIViewController

And in each .h file, set your view controller superclass to MyStyledViewController rather than plain old UIViewController.

这篇关于MFMessageComposeViewController外观iOS 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:32