Is there a way to make a custom animation when clicking on an iPhone button? I would like something like the App Store button - it shows the price, and then when you click on it, it changes color and the text changes to buy now, then when you click it again, it completes the purchase.
The UIViewAnimationTransition only contains a few values which don't provide the full functionality. Is it possible to do something like this but with the animation:
- (IBAction) changeButtonDisplay:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:purchaseButton cache:NO]; //the built in UIViewAnimationTransition values don't provide enough flexibility
[purchaseButton setTitle:@"Buy Now" forState:UIControlStateNormal];
[purchaseButton setBackgroundColor:[UIColor greenColor]];
[purchaseButton addTarget:self action:@selector(purchaseItems:) forControlEvents:UIControlEventTouchUpInside];
[UIView commitAnimations];
}
This code works and will display the proper transition and allow for the second click to do the proper action, but the title and color changes instantly, not in a smooth animation. Is it possible to do such an animation easily, of do I have to create a UIButton subclass and do the animation "manually"? If so, what method would I have to override?