【问题标题】:iOS: Line between navigation top bar and other contents of UIviewControlleriOS:导航顶栏和 UIviewController 的其他内容之间的线
【发布时间】:2017-08-12 16:15:45
【问题描述】:

我使用 Swift 3 和 Xcode 8.1 创建了一个应用程序,我有一个带有导航栏的视图控制器,我的视图在导航栏和其他 viewController 的内容之间显示了一条线(分隔符)。

我在viewDidLoad 中使用以下代码:

 self.navigationController?.navigationBar.isTranslucent = false 

但没有任何改变,更多详情请看截图:

我能做些什么来解决这个问题?

【问题讨论】:

    标签: ios swift3 xcode8.1


    【解决方案1】:

    试试:

    self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
    self.navigationController?.navigationBar.shadowImage = UIImage()
    

    如果您想将此效果应用于整个应用程序(这样您就不需要为每个导航控制器编写此代码),您可以使用:

    UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default)
    UINavigationBar.appearance().shadowImage = UIImage()
    

    【讨论】:

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