MFMessageComposeViewController appearance iOS 7

扶醉桌前 提交于 2019-12-05 02:36:43

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.

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]];

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

After digging around and trying a few different suggestions I arrived at a nice, non-hacky solution using a UINavigationController subclass.

This allows me to style all wanted nav bars once using the appearance proxy, with the exception of the MFMessageComposeViewController and MFMailComposeViewController which I'd prefer to look standard in order to communicate to the user that they are using core iOS functionality.

1 - Create a UINavigationController subclass.

2 - Style your nav bar using the appearance proxy as you were, but now using appearanceWhenContainedIn:

[[UINavigationBar appearanceWhenContainedIn:[KCStyledNavController class], nil] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearanceWhenContainedIn:[KCStyledNavController class], nil] setTintColor:[UIColor whiteColor]];

3 - Go into your storyboard, select all the the UINavigationControllers you want styled and change their custom class to your styled one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!