I want to put an animation to custom UIButton's title so that the numbers (each title shows a random assigned number) will come rotating. How can i do that?
The problem is i don't want to do this using flipping number images. i am wondering if there is any other way.
Assuming that you have a button called flipLabelButton
connected as IBOutlet
to your view controller, you can use this code to animate your button to a new label:
- (IBAction)flipLabelText:(id)sender {
NSString *newText = [NSString stringWithFormat:@"%d", rand() % 100];
[UIView beginAnimations:@"flipbutton" context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.flipLabelButton cache:YES];
[self.flipLabelButton setTitle:newText forState:UIControlStateNormal];
[UIView commitAnimations];
}