【问题标题】:Having issues with the navigation bar background color when transferring between 2 VCs在 2 个 VC 之间传输时出现导航栏背景颜色问题
【发布时间】:2018-01-19 19:21:54
【问题描述】:

我有一个HomeViewController,它推送到SendViewController,导航栏从深蓝色变为白色:

HomeViewController.swift:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.navigationBar.barStyle = .black
    navigationController?.navigationBar.barTintColor = Styleguide.Colors.darkBlue.color
    navigationController?.navigationBar.tintColor = Styleguide.Colors.lightBlue.color
}

 override func viewDidLoad() {
    super.viewDidLoad()

    view.backgroundColor = Styleguide.Colors.darkBlue.color

    navigationController?.navigationBar.barTintColor = Styleguide.Colors.darkBlue.color
    navigationController?.navigationBar.tintColor = Styleguide.Colors.lightBlue.color
    navigationController?.navigationBar.isTranslucent = false
    navigationController?.navigationBar.shadowImage = UIImage() // hides the bottom border
    self.navigationItem.hidesBackButton = true
    ... more 
}

SendViewController.swift

override func viewWillAppear(_ animated: Bool) {
   super.viewWillAppear(animated)
   self.navigationController?.navigationBar.barStyle = .default
}

override func viewWillDisappear(_ animated: Bool) {
   super.viewWillDisappear(animated)
   self.navigationController?.navigationBar.barStyle = .black
}

override func viewDidLoad() {
    super.viewDidLoad()

    view.backgroundColor = .white

    self.navigationController?.navigationBar.barTintColor = .white
    self.navigationController?.navigationBar.tintColor = Styleguide.Colors.darkBlue.color
    ... more
}

问题来了:

Send弹出到Home时,导航栏为白色,动画结束后跳转为深蓝色。 (期望的结果是在弹出时从白色变为深蓝色的动画)

【问题讨论】:

标签: ios swift uinavigationcontroller uikit uinavigationbar


【解决方案1】:

尝试添加

 navigationController?.navigationBar.barTintColor = Styleguide.Colors.darkBlue.color
 navigationController?.navigationBar.tintColor = Styleguide.Colors.lightBlue.color

查看SendViewController的WillDissapear

【讨论】:

  • 我有。没有什么不同的。在弹出动画完成之前,该条仍然是白色的,然后跳到深蓝色。因此我很困惑。
猜你喜欢
  • 1970-01-01
  • 2020-08-12
  • 2015-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-15
  • 1970-01-01
相关资源
最近更新 更多