1. 在Xcode 13.2.1 中,找不到從哪裏拖拽添加button控件
Xcode13起,添加UI控件需要點擊右上方的➕號
2. button的title屬性設置成ghost的emoji後,無法改變字體大小
需要把button的Style屬性由plain更改爲default
3. button.currentTitle 無法返回button的實際currentTitle,而是固定值Button
原因是我把button的Title屬性改爲Attributed了,改回plain即可獲取被按下button的currentTitle。
import UIKit class ViewController: UIViewController { @IBAction func touchCard(_ sender: UIButton) { flipCard(withEmoji: "👻", on: sender) } func flipCard(withEmoji emoji: String, on button: UIButton){ print("Log: " + button.currentTitle.unsafelyUnwrapped) if button.currentTitle == emoji{ button.setTitle("", for: UIControl.State.normal) button.backgroundColor = UIColor.orange }else{ button.setTitle(emoji, for: UIControl.State.normal) button.backgroundColor = UIColor.white } } }