【发布时间】:2016-09-15 16:58:08
【问题描述】:
我正在尝试创建自定义导航栏,但在修改导航栏的不同部分时遇到了困难。我可以更改背景的颜色,但似乎无法添加按钮或更改标题。
class CustomNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// changing the background color works
self.navigationBar.barTintColor = UIColor.purpleColor()
// none of this works
let leftButton = UIBarButtonItem(title: "Info", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(openInfo))
self.navigationItem.leftBarButtonItem = leftButton
self.navigationItem.title = "MYTITLE"
}
}
我不确定我尝试将此 NavigationController 与 TabBarController 集成这一事实是否会影响视图加载方式,但此自定义 NavigationController 正在被 TabBarController 中的每个选项卡子类化。
【问题讨论】:
标签: ios swift uinavigationcontroller