iOS 7:禁用整个应用程序的 UINavigationBar 半透明 [英] iOS 7 : Disable UINavigationBar Translucency For Entire App
问题描述
有没有办法为整个应用程序禁用 UINavigationBar Translucency?
Is there a way to disable UINavigationBar Translucency for an entire application?
我知道使用 [self.navigationController.navigationBar setTranslucent:NO]
可以解决单个控制器的这个问题,但我的应用程序中有很多 UINavigationBars,这是一个很好的繁琐的解决方案.
I'm aware that using [self.navigationController.navigationBar setTranslucent:NO]
can fix this issue for a single controller, but I have a lot of UINavigationBars in my application and this is a pretty tedious solution.
我已经尝试过[[UINavigationBar appearance] setTranslucent:NO]
,但令人惊讶的是不支持该功能.这样做会导致 由于未捕获的异常NSInvalidArgumentException"而终止应用程序,原因:***非法的属性类型,c 表示外观设置器,_installAppearanceSwizzlesForSetter:"
I've tried [[UINavigationBar appearance] setTranslucent:NO]
, but that functionality is surprisingly not supported. Doing that results in Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, c for appearance setter, _installAppearanceSwizzlesForSetter:'
如果必须的话,我可以通过我的整个应用程序设置 UINavigationBars 来一个一个地禁用半透明,但必须有一些更优雅的解决方案来解决这个问题......
If I HAVE to, I can go through my entire app setting UINavigationBars to disable translucency one by one, but there must be some more elegant solution to this issue...
推荐答案
如果将栈中第一个导航栏的半透明设置为 false
[self.navigationController.navigationBar setTranslucent:NO]
,它将反映在所有推送到该堆栈的以下 NavigationViewController 中.
if you set the translucence of the first navigation bar in the stack to false
[self.navigationController.navigationBar setTranslucent:NO]
, it will reflect in all the following NavigationViewController that are pushed to that stack.
这篇关于iOS 7:禁用整个应用程序的 UINavigationBar 半透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!