こんにちは
現在タイマーアプリを作って一応完成はしたのですが、数字が変わるごとに文字がガタガタ動いてしまいます。
一応AutoLayoutで幅と位置を固定しているのですが、こればかりはどうしようも無いものなのでしょうか?
よろしくお願いいたします
swift
1import UIKit 2 3class StartTimerViewController: UIViewController { 4 5 //タイマー 6 var timer = NSTimer() 7 var countNum: Int = 0 8 var timerRunning: Bool = false 9 10 //update 11 func update(){ 12 countNum += 1 13 let hour = countNum/3600 14 let minute = (countNum - hour*3600)/60 15 let second = countNum - hour*3600 - minute*60 16 countLabel.text = "\(String(format: "%02d",hour)):\(String(format: "%02d",minute)):\(String(format: "%02d",second))" 17 } 18 19 //startBtn 20 @IBAction func tapStartBtn(sender: AnyObject) { 21 if !timerRunning{ 22 timer = NSTimer.scheduledTimerWithTimeInterval(0.01, target: self, selector: #selector(StartTimerViewController.update), userInfo: nil, repeats: true) 23 timerRunning = true 24 } 25 } 26 27 @IBAction func tapStopBtn(sender: AnyObject) { 28 if timerRunning{ 29 timer.invalidate() 30 timerRunning = false 31 } 32 } 33}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/04 15:12
2016/05/04 15:14