首页 > 编程语言 > 详细

swift 动画转场要在主线程

时间:2018-11-12 13:50:28      阅读:131      评论:0      收藏:0      [点我收藏+]
        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 动画转场要在主线程

原文:https://www.cnblogs.com/iaoc/p/9945960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!