试试这个:在ViewDidLoad
let backButton = UIBarButtonItem(title: "< Home", style: UIBarButtonItemStyle.Plain, target: self, action: "goBack")
navigationItem.leftBarButtonItem = backButton
navigationItem.backBarButtonItem?.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "the_font_you_want_to_use", size: size_of_the_font_this_should_be_integer)!], forState: UIControlState.Normal)
并实现以下方法:
func goBack() {
self.navigationController?.popToRootViewControllerAnimated(boolean)
}
只需将 the_font_you_want_to_use、size_of_the_font_this_should_be_integer 和 boolean 替换为您想要的值,一切都会正常工作。
*** 编辑
如果你不想回到Root View Controller
, 而不是
self.navigationController?.popToRootViewControllerAnimated(boolean)
你可以说:
self.navigationController?.popViewControllerAnimated(boolean)
甚至ViewController
通过指定第一个参数为类popToViewController
的对象YourViewController
,第二个是动画的布尔值来弹出其他参数。