【问题标题】:UINavigationBar set Background, and set translucent not workingUINavigationBar 设置背景,并设置半透明不起作用
【发布时间】:2016-05-18 08:11:08
【问题描述】:

我正在尝试在代码中的 ViewWillAppear 函数中设置 UINavigation 栏的背景和透明度。但是它似乎不起作用。

self.navigationController!.navigationBar.translucent = false
self.navigationController!.navigationBar.backgroundColor = UIColor.blackColor()

视图控制器通过情节提要 id 加载

  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewControllerWithIdentifier(storyboardId)
  vc.title = storyboardId
  let navigationController = UINavigationController(rootViewController: vc)
  self.presentViewController(navigationController, animated: false, completion: nil)

我也试过设置,好像不行。

此外,我尝试使用 UINavigationBar.appearance() 设置属性,这也不起作用。

【问题讨论】:

标签: ios swift uinavigationcontroller uinavigationbar


【解决方案1】:

你可以试试这个:

self.navigationController?.barTintColor = UIColor.blackColor()

【讨论】:

    猜你喜欢
    • 2016-10-23
    • 2018-11-23
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2018-12-25
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多