【问题标题】:My navigation bar is transparent, yet now messages app navigation bar is transparent, too我的导航栏是透明的,但现在消息应用导航栏也是透明的
【发布时间】:2014-02-15 04:06:44
【问题描述】:

我已将导航栏设为透明,这很棒。然而,现在当我在我的应用程序中切换到消息应用程序时,导航栏也是透明的,这看起来真的很奇怪。消息仅被部分屏蔽并从顶部显示。

这是我在appDelegate 中所做的,以使导航栏消失:

[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];

您可以想象,在消息应用程序中没有导航栏是很奇怪的。如何将其更改回此视图?

【问题讨论】:

  • 能否在将其设置为空图像之前调用 backgroundImageForBarMetrics,缓存结果,然后在需要非透明条时调用 setBackgroundImage 并将原始图像传回?
  • jeffamaphone 你提出了一个非常好的建议。但是,我在使用上面的代码之前尝试保存图像,但我仍然只得到一个 nil 图像。奇怪的。无论如何,谢谢你的想法。

标签: ios navigationbar


【解决方案1】:

您应该在系统消息 VC 呈现之前和关闭之后再次设置该外观。 UIAppearance 确实改变了应用内所有类的外观,包括系统提供的 VC。

谢谢,jbouaziz。 看看这个问题:Override UIAppearance property for MFMailComposeViewController

【讨论】:

  • 没错,你应该添加一些代码。你刚才说的在这里解释stackoverflow.com/a/15580732/1835155。可能有一种更清洁的方法,但是......它可以完成工作!
【解决方案2】:

我受到您的回答的启发,这就是我修复它的方法。首先,在调用消息应用程序显示的方法中,我将导航栏的图像设置为 nil,这会将其恢复为默认外观。

[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];

然后在用户返回的视图控制器的 viewWillAppear 方法中,我再次使用了这段代码

[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

【讨论】:

    猜你喜欢
    • 2018-09-21
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多