ラベルに5秒からカウントダウンを行ない0になったら、9秒ごとにカウントアップを7回繰り返したいのですが、以下のコードでは上手くいきません。どのように変更すれば良いのか教えてください。
swift
1 2timer1 = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: { (timer) in 3 4 //カウントダウン 5 self.count = self.count - 1 6 7 //ラベルに反映 8 self.countLabel.text = String(self.count) 9 10 if (self.count < 0) { 11 12 self.timer2 = Timer.scheduledTimer(withTimeInterval: 9.0, repeats: true, block: { (timer) in 13 14 //9秒ごとにカウントアップ 15 self.count = self.count + 1 16 self.countLabel.text = String(self.count) 17 }) 18 19 20 } 21 22 23 })
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/10 09:51
2018/12/10 09:58
2018/12/10 16:56 編集
2018/12/10 12:38
2018/12/11 00:07