gpt4 book ai didi

ios - 使用 animatewithduration 移动 ImageView

转载 作者:行者123 更新时间:2023-11-28 10:24:20 25 4
gpt4 key购买 nike

我试图多次移动图像。这就是我尝试实现它的方式。

override func viewDidAppear(animated: Bool) {

UIView.animateWithDuration(1, animations: { () -> Void in

self.sattelite.center.x = 50
self.sattelite.center.y = 100

self.sattelite.center.x = 50
self.sattelite.center.y = 50

self.sattelite.center.x = 50
self.sattelite.center.y = 300



})

}

然而,animatewithduration 方法只执行其中一个 Action 。有什么方法可以为 ImageView 的所有三个运动设置动画吗?谢谢。

最佳答案

您可以轻松地链接动画;在完成时开始另一个:

  • 这里有一个例子:

    //1st animation
    UIView.animateWithDuration(1.0,
    delay: 0.0,
    options: .CurveEaseInOut | .AllowUserInteraction,
    animations: {
    //some code ex : view.layer.alpha = 0.0
    },
    completion: { finished in

    //second animation at completion
    UIView.animateWithDuration(1.0
    , delay: 0.0,
    , options: .CurveEaseInOut | .AllowUserInteraction,
    , animations: { () -> Void in

    //some code ex : view.layer.alpha = 1.0

    }
    , completion: { finished in

    //third animation at completion
    UIView.animateWithDuration(1.0,
    delay: 0.0,
    options: .CurveEaseInOut | .AllowUserInteraction,
    animations: {
    //some code ex : view.layer.alpha = 0.0
    },
    completion: { finished in
    //FINISH : 3 animations!!!
    })


    })
    })

关于ios - 使用 animatewithduration 移动 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29781514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com