###前提・実現したいこと
Swiftで0以下になったら色が変わるカウンターを作りたいのですが、この先、どう書けばいいかわかりません。
swift
1import UIKit 2 3class ViewController: UIViewController { 4 5 @IBOutlet weak var count0: UILabel! 6 var num:Int = 0 7 8 9 override func viewDidLoad() { 10 super.viewDidLoad() 11 // Do any additional setup after loading the view, typically from a nib. 12 } 13 14 override func didReceiveMemoryWarning() { 15 super.didReceiveMemoryWarning() 16 // Dispose of any resources that can be recreated. 17 } 18 19 func updateCounter(num: Int) { 20 count0.text = String(num) 21 22 } 23 24 @IBAction func countPlus(sender: AnyObject) { 25 num += 1 26 updateCounter(num) 27 28// count0.textColor = UIColor.blueColor() 29 } 30 31 @IBAction func countMinus(sender: AnyObject) { 32 num -= 1 33 updateCounter(num) 34 35// count0.textColor = UIColor.redColor() 36 } 37}
今はこんな感じで煮詰まっています。
画面にエラーなどはありません。
アドバイスよろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/04 06:14