0

画像を複数回移動しようとしています。これは私がそれを実装しようとした方法です。

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 メソッドは、動きの 1 つだけを実行します。画像ビューの 3 つの動きすべてをアニメーション化する方法はありますか? ありがとう。

4

3 に答える 3

2

アニメーションを簡単に連鎖できます。完了時に別の開始:

  • ここにイラストがあります:

    //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!!!
                    })
    
    
            })
    })
    
于 2015-04-21T19:44:20.970 に答える
1

完成したアニメーションをチェーンするか、キー フレーム アニメーションを使用する必要があります。

于 2015-04-21T19:43:52.423 に答える