Reputation: 435
I have two UIButton Let say:
UIButton *product UIButton *nextProduct
i am setting the image on each button with respect to the product.
i want to animate the buttons in such a way that one button fadein while second is fadeout.
kindly help me out
Upvotes: 2
Views: 703
Reputation: 2535
I Would use the new block API instead. I don't know if the first answer would let the user interact with the controls during the animations. I had a similar case and used the code beneath. The key is the options:UIViewAnimationOptionAllowUserInteraction
[UIView animateWithDuration:0.5f
delay:0.0f
options:UIViewAnimationOptionAllowUserInteraction
animations:^(void) {
[product setAlpha:0.0f];
[nextProduct setAlpha:1.0f];
} completion:^(BOOL finished) {
//Maybe set the new alpha here when the first animation is done?
}];
Upvotes: 1
Reputation: 6259
Wrap the changes you want animated between UIView beginAnimations
and UIView commitAnimations
.
[UIView beginAnimations:nil context:nil];
product.alpha = 0;
nextProduct.alpha = 1;
[UIView commitAnimations];
Check the UIView documentation for how to customize timing and appearance.
Upvotes: 0