0
我想創建一個非常簡單的計數器,用戶點擊一個按鈕,文本框按順序1顯示,然後按2,然後按3,然後重置爲1,然後再次使用相同按鈕。Swift 2計數器和復位
到目前爲止我的代碼:
class Counter: UIViewController {
var count = 1
@IBOutlet weak var sectors: UITextField!
@IBAction func numberSectors(sender: UIButton) {
if count < 3 {
count+=1
sectors.text = "\(count)"
}
else {
sectors.text = "0"
}
}
}
這麼簡單!非常感謝。 – smi6086