Swift3淡入/淡出或平滑过渡UIImageView animationImages

时间:2017-04-01 21:51:07

标签: ios swift swift3 uiimageview uiviewanimationtransition

我正在尝试制作图片幻灯片

在UIImageView(Swift3)中为animationImages添加平滑过渡的最佳方法是什么

这里是我的幻灯片代码:

        DispatchQueue.main.async {
                imageView.animationImages = activeImages
                imageView.clipsToBounds = true
                imageView.animationDuration = (1.0 * Double(activeImages.count))
                imageView.animationRepeatCount = Int.max
                imageView.startAnimating()
         }

1 个答案:

答案 0 :(得分:0)

使用UIVIew.animate块和两个UIImageViews进行转换,它们通常被使用并生成非常干净的代码。

UIView.animate(withDuration: 0.3,
               delay: 0,
               options: .curveEaseInOut, //just an example, check UIViewAnimationOptions
               animations: {
      self.image1.alpha = 0
      self.image2.alpha = 1
})