如何为导航栏按钮项设置动态标题?

时间:2019-07-19 07:36:34

标签: swift

我必须将当前位置字符串设置为右键栏

var locationStr = String()

override func viewDidLoad()

{
    super.viewDidLoad()

 let newBackButton = UIBarButtonItem(title: locationStr , style: UIBarButtonItem.Style.plain, target: self, action: nil)

 self.navigationItem.rightBarButtonItem = newBackButton
}

但是没有显示条形按钮标题

0 个答案:

没有答案