swift - 当我显示新的 UIView 时,UINavigationBar 失去色调颜色

标签 swift uinavigationcontroller uinavigationbar

我通过 AppDelegate 中的以下代码行向 UINavigationBar 添加了色调:

let navBar = UINavigationBar.appearance()
navBar.barTintColor = mainColor

first view controller

但是,当我通过 segue 进入不同的 View 时,我失去了颜色。 View 2 未嵌入其自己的 UINavigationController 中。

View 2

如果我将它嵌入到导航 Controller 中,它就会出现,但是如果我从 View 2 转到 View 3,它也会消失。

我使用“显示”作为 segue 选项。

最佳答案

我使用了 @IBAction 操作从 View 2 转到 View 3。这就是我必须替换的原因

navigationController?.popViewControllerAnimated(true)

具有以下内容:

self.dismissViewControllerAnimated(true, completion: nil)

我是通过 - Go back to previous view controller doesn't work 了解到这一点的

关于swift - 当我显示新的 UIView 时,UINavigationBar 失去色调颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37158387/

相关文章:

ios - 导航栏中带有大标题或搜索栏的 UIRefreshControl 的故障动画

ios - 更改 UINavigationBar 的半透明度具有相反的效果

ios - 在 View 层次结构中保持 UITabBarController 可见( Storyboard)

iOS 导航栏 VS UIToolBar

swift - 带闭包的属性初始化

json - 在 Swift 2.0 中从 JSON 对象获取值

ios - 如何设置右侧导航栏按钮标题

导航栏中的ios标题和副标题居中

swift 4 : generic conforming to AnyObject does not accept a protocol conforming to AnyObject

ios - 在 ios swift 中自定义 Twitter 数字