【问题标题】:Swift3 Fade in/Fade out or Smooth transition UIImageView animationImagesSwift3 淡入/淡出或平滑过渡 UIImageView animationImages
【发布时间】:2017-04-01 21:51:06
【问题描述】:

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

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

这里是我的幻灯片代码:

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

【问题讨论】:

    标签: ios swift swift3 uiimageview uiviewanimationtransition


    【解决方案1】:

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

    【讨论】:

    • 我想要一个无限重复的幻灯片,包含 20 张图片,我认为 UIVIew.animate 更适合临时动画,不是吗?
    • 这个响应不是用户想要在这里解决的
    猜你喜欢
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多