目次
- ProgressViewとLabelの配置
- ProgressViewとLabelをコードと接続
- Timerの実装
- シュミレーターで確認
ProgressViewとLabelの配置
ProgressViewとLabelをコードと接続
変数の設定
Timerの実装
- remainingTime = 15
-
- progressView.progress = 1.0
-
- timeLabel.text = "15"
-
- quizTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timeF), userInfo: nil, repeats: true)
- @objc func timeF() {
-
- remainingTime -= 1
-
- progressView.progress = Float(remainingTime) / 15
-
- timeLabel.text = String(remainingTime)
-
- if remainingTime == 0 {
-
- quizTimer!.invalidate()
-
- questionNumber += 1
-
- question()
-
- }
- }
- @IBAction func buttonChack(_ sender: Any) {
-
- quizTimer!.invalidate()
-
- .
- .
- .
- .
-
シュミレーターで確認
0 件のコメント:
コメントを投稿