动画时UIImageView返回到原始位置

时间:2019-12-02 02:34:41

标签: ios swift animation

我正在尝试为我的应用制作动画。我想将图像移到UIView(动画背景)的中心,然后更改该UIView(背景)的高度,这时出现了问题-我的图像转到原始位置。这是我的代码:

UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
            animationView.alpha = 1
        }) { (true) in
            UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
                infoImage.center.x = animationView.center.x
            }) { (true) in
                UIView.animate(withDuration: 1, delay: 0.5, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
                    animationView.frame = CGRect(x: 8, y: cellFrame.minY, width: cellFrame.width - 16, height: cellFrame.height + 200)
                }) { (true) in
                    print("completed")
                }
            }
        }

动画的第一块只是使其可见。该动画的第二个块将图像移到中心。第三块增加UIVIew的高度。 屏幕截图: Screenshot

1 个答案:

答案 0 :(得分:0)

这是因为您要覆盖x值。

add2DF()