override func viewDidLoad() {
super.viewDidLoad()
let button1 = UIButton(frame: CGRect(x: 50, y: 50, width: 30, height: 30))
button1.setTitle("hi", for: .normal)
button1.setTitleColor(.blue, for: .normal)
button1.setTitleColor(.black, for: .highlighted)
button1.addTarget(self, action: #selector(self.barItem2Clicked(sender:)), for: .touchUpInside)
button1.backgroundColor=UIColor.red
let barButton1 = UIBarButtonItem(customView: button1)
toolBar1.items?.append(barButton1)
}
方法
barItem2Clicked
:
func barItem2Clicked(sender :Any?) {
NSLog("hello")
}
button1
无法调用,高亮显示的效果也不会显示。
按钮1
我只是补充了一下,但是方法
从未打过电话。
我错过什么了吗?