如何在Swift 3中设置editButtonItem标题

时间:2016-09-19 03:34:58

标签: ios iphone swift swift3

我知道在Swift 2.2中很容易。像这样:

editButtonItem().title = "My Title"

但在Swift 3中,editButtonItem成为UIViewController的属性。并且UIBarButtonItem不再拥有标题。所以这不起作用:

editButtonItem.title = "My Title" // doesn't work

请帮帮我!谢谢!

1 个答案:

答案 0 :(得分:0)

  1. 这可能对您有帮助!

    let navigationBar = navigationController!.navigationBar
    navigationBar.tintColor = UIColor.blueColor()
    
    let leftButton =  UIBarButtonItem(title: "Left Button", style: UIBarButtonItemStyle.Plain, target: self, action: nil)
    navigationItem.leftBarButtonItem = leftButton