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)
                }
                
            }
        }

 

posted @ 2018-11-12 13:33  举起希望之灯  阅读(523)  评论(0)    收藏  举报