Jiraheta
Jiraheta

Reputation: 481

IOS app switching animation "A" with animation "B" in the same place

I have 2 animations. The initial one when the app loads, and a second one which will be the one that stays put through the remainder of the user experience.

Here is what i want to do in the nutshell

1) animation "A" which loads when the app loads. 2) then i want to hide animationa "A" and replace it with animation "B" on the same coordinates 3) have animation "B" play any other time or on an interval of 30 seconds or 45

Animation A

[UIView animateWithDuration:2.5 
                      delay:2.0 
                    options:UIViewAnimationCurveEaseIn
                 animations:^{[buhoButton setFrame:CGRectMake(91, 185, 130, 130)];}completion:nil];

Animation B

animation.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"Buho128x128_0.png"],
                                  [UIImage imageNamed:@"Buho128x128_1.png"],
                                  [UIImage imageNamed:@"Buho128x128_2.png"],
                                  [UIImage imageNamed:@"Buho128x128_3.png"],
                                  [UIImage imageNamed:@"Buho128x128_4.png"],
                                  [UIImage imageNamed:@"Buho128x128_3.png"],
                                  [UIImage imageNamed:@"Buho128x128_2.png"],
                                  [UIImage imageNamed:@"Buho128x128_1.png"],
                                  [UIImage imageNamed:@"Buho128x128_0.png"], nil];
[animation setAnimationRepeatCount:-1];
animation.animationDuration = 1;
[animation startAnimating];

is this possible?

Upvotes: 0

Views: 164

Answers (2)

Michael Mangold
Michael Mangold

Reputation: 1801

If you want control over when animation B triggers you could use a CABAsicAnimation with removedOnCompletion = YES for animation A (placed in your viewDidLoad) and removedOnCompletion = NO for animation B (placed where your tiggering event is handled).

Upvotes: 1

ale84
ale84

Reputation: 1406

try putting the code for Animation B into the completition block of Animation A:

[UIView animateWithDuration:2.5 
                  delay:2.0 
                options:UIViewAnimationCurveEaseIn
             animations:^{[buhoButton setFrame:CGRectMake(91, 185, 130, 130)];}
             completion:^(BOOL finished){/*Animation B code here*/;}
];

Upvotes: 1

Related Questions