swift 動畫轉場要在主線程
阿新 • • 發佈:2018-11-12
swift lob 動畫 view div anim wan print light
let animation = UIViewAnimation() animation.animate(view: self.background, fn: { DispatchQueue.main.async { self.setCoverImage(coverUrl: coverUrl) } print("轉場1") }) { print("轉場完成") DispatchQueue.global().async { self.reload(url: url, coverUrl: coverUrl, callFn: callFn) } }
上面方式死活不回調成功函數。換用下面方式則成功
DispatchQueue.main.async { let animation = UIViewAnimation() animation.animate(view: self.background, fn: { self.setCoverImage(coverUrl: coverUrl) print("轉場1") }) { print("轉場完成") DispatchQueue.global().async { self.reload(url: url, coverUrl: coverUrl, callFn: callFn) } } }
swift 動畫轉場要在主線程