iOSアプリ開発 Swiftでクイズアプリを作ってみる 時間制限の追加

2019年8月3日土曜日

iosアプリ開発 Swiftでクイズアプリを作ってみる

t f B! P L






目次
  1. ProgressViewとLabelの配置
  2. ProgressViewとLabelをコードと接続
  3. Timerの実装
  4. シュミレーターで確認






ProgressViewとLabelの配置



ProgressViewとLabelをコードと接続













変数の設定
Timerの実装
  1. remainingTime = 15
  2. progressView.progress = 1.0
  3. timeLabel.text = "15"
  4. quizTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timeF), userInfo: nil, repeats: true)
  1. @objc func timeF() {
  2. remainingTime -= 1
  3. progressView.progress = Float(remainingTime) / 15
  4. timeLabel.text = String(remainingTime)
  5. if remainingTime == 0 {
  6. quizTimer!.invalidate()
  7. questionNumber += 1
  8. question()
  9. }
  10. }
  1. @IBAction func buttonChack(_ sender: Any) {
  2. quizTimer!.invalidate()
  3.  
  4. .
  5. .
  6. .
  7. .




シュミレーターで確認





keep175
Illustrator,photoshop,アプリ開発の勉強中です。

アーカイブ

QooQ