jean bernard
jean bernard

Reputation: 257

two UIView Animation on the same image

Well I would like to have two UIView animation on a same image in the same method like this :

-(void)likeThis{
[UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        image.alpha=0;
        [UIView commitAnimations];

    [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        image.transform = CGAffineTransformScale(5,5);
        [UIView commitAnimations];

}

But there is only one of these UIView Animation who work.I don't know why.I think there is another way to put two animation for the same image but I don't know how. sorry for my english I'm french :/

Upvotes: 0

Views: 314

Answers (2)

jkira
jkira

Reputation: 1150

You can just put them in the same animation block:

-(void)likeThis
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationDelegate:self];
    image.alpha=0;
    image.transform = CGAffineTransformScale(image.transform,5,5);
    [UIView commitAnimations];
}

Note that CGAffineTransformScale takes three arguments:

CGAffineTransformScale(image.transform, 5.0, 5.0)

See http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/doc/uid/TP30000946-CH1g-F16985

Or you could use CGAffineTransformMakeScale: http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/c/func/CGAffineTransformMakeScale

Upvotes: 3

Owen Hartnett
Owen Hartnett

Reputation: 5935

Do you want them to happen simultaneously, or one after the other? If the former just include them both between a single set of beginAnimations..commitAnimations calls

Upvotes: 2

Related Questions