【问题标题】:remove border of navigation bar for few view controllers移除少数视图控制器的导航栏边框
【发布时间】:2015-11-14 05:18:22
【问题描述】:

我想删除导航栏的边框。我在 AppDelegate.m 中使用此代码

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init]
                              forBarPosition:UIBarPositionAny
                                  barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];

而且效果很好。它删除了每个视图控制器中导航栏的边框。 但我必须为少数视图控制器删除它。

通过将此代码放在特定视图控制器的 viewWillAppear 中,它不起作用。 有人知道怎么做吗?

【问题讨论】:

  • 您应该在选择的导航栏中设置导航栏的背景图像和阴影图像,不要使用外观方法。例如:` [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]`
  • 谢谢....现在它的工作:)
  • 我将在我的评论中添加一个答案,以便您接受并关闭此问题。

标签: ios


【解决方案1】:

您应该在选择的导航栏中设置导航栏的背景图像和阴影图像,而不是使用外观方法。例如:

    [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
 forBarMetrics:UIBarMetricsDefault];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 2014-12-09
    • 1970-01-01
    • 2018-04-19
    相关资源
    最近更新 更多