//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