开发者

How to control animation speed?

开发者 https://www.devze.com 2023-04-02 06:02 出处:网络
I\'m moving an image and then expanding the image. The problem is my image is moving way to fast. Is there a way to to allow 2 animations to run and to control the speed? Here is the code:

I'm moving an image and then expanding the image. The problem is my image is moving way to fast. Is there a way to to allow 2 animations to run and to control the speed? Here is the code:

- (IBAction)pushmove {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDurat开发者_开发问答ion:2.5];
    square.transform = CGAffineTransformMakeTranslation(-200,-300);
    [UIView setAnimationDuration:1.5];
    square.transform = CGAffineTransformMakeScale(8,8);
    [UIView commitAnimations];


Yes!

It's possible and fairly straightforward. The key thing is thatCAAnimationimplements theCAMediaTimingprotocol. So either on theCAAnimationorCAAnimationGroupyou can set the speed as follows:

myAnimationGroup.speed = 2;

So if duration is4, your group will execute in2seconds.

Some of Apple's videos are very helpful on this subject. WWDC 2010 Session 424 coversCAMediaTimingand it's uses. Checkout 46:30 seconds into the video.

Here's the link: WWDC 2010 Sessions

0

精彩评论

暂无评论...
验证码 换一张
取 消