var backButton: UIBarButtonItem = UIBarButtonItem(title: "CUSTOM", style: UIBarButtonItemStyle.Bordered, target: self, action: nil)
newNavigationItem.backBarButtonItem = backButton
newNavigationItem: UINavigationItem
我想要自定义后退标题。它显示“后退”文本或“最后一个视图的标题”。所以它不起作用。为什么呢?
答案 0 :(得分:13)
Yogesh Suthar说的方法将取代整个后退按钮,所以你不会有默认的左箭头标志!我建议使用这段代码:
closed = True
答案 1 :(得分:5)
使用leftBarButtomItem
newNavigationItem.backBarButtonItem = backButton
应该是
newNavigationItem.leftBarButtonItem = backButton
答案 2 :(得分:2)
override func viewDidLoad() {
super.viewDidLoad()
let newBackButton = UIBarButtonItem(title: "Back",
style: UIBarButtonItemStyle.Plain, target: self, action: "backAction")
navigationController?.navigationBar.topItem?.backBarButtonItem = newBackButton
}
func backAction() -> Void {
self.navigationController?.popViewControllerAnimated(true)
}