Swift UIBarButtonItem标题

时间:2019-06-05 19:17:59

标签: ios swift uibarbuttonitem

@IBAction
func buttonTapped(_ sender: UIBarButtonItem) {
  guard let title = sender.currentTitle,
        let button = Buttons(rawValue: title) else { return }
}

我遇到的错误是“ UIBarButtonItem类型的值没有成员'currentTitle',每个按钮都有枚举和大小写。

1 个答案:

答案 0 :(得分:0)

尝试gaurd let title = sender.title