在下面的代码中,我使用swift 2创建了2个右键。
此刻,我想做出类似的事情:
accountButton.disable = false
但这是不可能的。
禁用此栏按钮的最佳解决方案是什么?
let accountImage = UIImage(named: "account")!
let settingImage = UIImage(named: "setting")!
let accountButton = UIBarButtonItem(image: accountImage, style: .Plain , target: self, action: "didTapEditButton:")
let settingButton = UIBarButtonItem(image: settingImage, style: .Plain, target: self, action: "didTapSearchButton:")
navigationItem.rightBarButtonItems = [accountButton , settingButton]
答案 0 :(得分:4)
尝试:
Swift 2
accountButton.enabled = false
Swift 3
accountButton.isEnabled = false
答案 1 :(得分:0)
使用UIBarButtonItem
的属性enabled
代替disable