5秒からカウントダウンして、0になったらラベルに1から表示したいのですが、このままでは0からになってしまいます。だからと言って、if (self.count == 1)とすると音楽とタイマーがずれてしまいます。良いアイディアがある方はいらっしゃいますか。
Swift
1timer1 = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: { (timer) in 2 3 //カウントダウン 4 self.count = self.count - 1 5 6 //ラベルに反映 7 self.countLabel.text = String(self.count) 8 9 if (self.count == 0) { 10 11 //タイマー1ストップ 12 self.timer1.invalidate() 13 self.timer2 = Timer.scheduledTimer(withTimeInterval: 9.0, repeats: true, block: { (timer) in 14 15 //9秒ごとにカウントアップ 16 self.count = self.count + 1 17 self.countLabel.text = String(self.count) 18 }) 19 20 21 }``` 22 23 24`` 25 26コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。