Do you make your changes inside the Core Animation block?
I created a simple iPhone based application to test this. The view has two rounded rectangular UIButton objects:
The first button is in the upper right corner with a width of 62 (and a height of 35) and the initial name is "$ 0.99". It is connected to the "button" connector and "animate" the action in the view controller. This is the button that will be animated when it is clicked.
The second button is located at the bottom of the screen with the name "Reset" and is connected to the "Reset" action in my view controller.
Here is the view controller code:
UIButtonAnimationTestViewController.h:
UIButtonAnimationTestViewController.m:
#import "UIButtonAnimationTestViewController.h" @implementation UIButtonAnimationTestViewController - (void)viewDidLoad { [super viewDidLoad]; originalFrame = button.frame; } - (IBAction)animate { CGRect frame = button.frame; frame.origin.x -= 30; frame.size.width += 30; [UIView beginAnimations:@"button" context:nil]; button.frame = frame; [button setTitle:@"" forState:UIControlStateNormal]; [UIView setAnimationDelegate:self]; [UIView commitAnimations]; } - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [button setTitle:@"BUY NOW" forState:UIControlStateNormal]; } - (IBAction)reset { button.frame = originalFrame; [button setTitle:@"$0.99" forState:UIControlStateNormal]; }
gerry3
source share