0
whileループでUIView
の色を変更したいと思います。私はstart()
をメインスレッドから呼んでいます。whileループでUIViewの背景色を更新する
例:あなたは色がシーケンス内の次に1から変更したい場合は、前のアニメーションは次のものとして仕上がっているので、あなたのアニメーションが遅延し、期間値で呼び出しを提出する必要が
func start() {
let item = Percolation(n: self.tileSideCount)
while (!item.percolates()) {
let v = Int(arc4random_uniform(UInt32(self.tileSideCount))) + 1
let j = Int(arc4random_uniform(UInt32(self.tileSideCount))) + 1
UIView.animate(withDuration: 0.3, delay: 0.0, options: [], animations: {
self.container?.viewWithTag(v)?.backgroundColor = UIColor.white
self.container?.viewWithTag(j)?.backgroundColor = UIColor.white
}, completion: { (finished: Bool) in
})
if (!item.isOpen(i: v, j: j)) {
item.open(i: v, j: j);
}
}
}
'self.container?.viewWithTag(v/j)'はゼロになる可能性があります – Callam
どの部分がうまくいかないのですか? – Losiowaty
ビューの背景色を無作為に白に変更していますか? –