//This is the label
let changeLbl = UILabel(frame: CGRect(x: 20, y: 170, width: 300, height: 21))
self.view.addSubview(changeLbl)
//This is the button
let submitButton = UIButton(type: .system) // let preferred over var here
submitButton.addTarget(self, action: #selector(buttonAction) , for: UIControlEvents.touchUpInside)
self.view.addSubview(submitButton)
//and this is action of above button
func buttonAction(sender: UIButton!) {
}
我想打电话给下面的按钮功能上面的标签吗?像如何调用/按钮操作访问标签编程?
func buttonAction(sender: UIButton!) {
changeLbl.ishidden = true
//想在这里访问的标签,但它不是以这种方式工作。 }
你面临的问题是什么? – shallowThought
我不能让访问按钮功能标签... @shallowThought – Bilal
到底会发生什么“我不能让访问标签”?编译错误?运行时错误?哪一个? – shallowThought