码迷,mamicode.com
首页 > 编程语言 > 详细

swift 动画转场要在主线程

时间:2018-11-12 13:52:47      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:回调   async   round   nim   完成   div   ima   self   swift   

        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 动画转场要在主线程

标签:回调   async   round   nim   完成   div   ima   self   swift   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!