UIButton of custom type incorrectly animate width and height changes.

Originator:NitroPye
Number:rdar://7290242 Date Originated:09-Oct-2009 10:57 AM
Status:Open Resolved:
Product:iPhone SDK Product Version:3.1.2
Classification: Reproducible:Always
 
09-Oct-2009 10:57 AM Coleman Nitroy:
Summary:
Animating a UIButton produces different results then animating a different type of UIView.  

Steps to Reproduce:
        // Using a UIImageView to demonostrate the working animations.
        CGRect frame = CGRectMake(0,0, 50, 50);      
	UIImageView *zoomView = [[UIImageView alloc] initWithFrame:frame];
        zoomView.image = [UIImage imageNamed:@"someimage.png"];
	[self.view addSubview:zoomView];

	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration: 2];
	frame.origin.x = 20;
        frame.size.width = 100;
	frame.size.height = 100;
	zoomView.frame = frame;
	[UIView commitAnimations];

        // Using a custom UIButton with the same frame translations
        frame = CGRectMake(0,0, 50, 50);      
	UIButton *zoomView = [[UIButton alloc] initWithFrame:frame];
        [zoomView setImage:[UIImage imageNamed:@"someimage.png"] forState:UIControlStateNormal];
	[self.view addSubview:zoomView];

	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration: 2];
	frame.origin.x = 20;
	frame.size.width = 100;
	frame.size.height = 100;
	zoomView.frame = frame;
	[UIView commitAnimations];

Expected Results:
Both views should animate along the X axis 20, and grow to 100x100 in size.

Actual Results:
The UIImageView moves along the X axis and grows to 100x100. The UIButton moves along the X axis but frame size changes instantly instead of over 2 seconds time set by [UIView setAnimationDuration:2];

Regression:
I am able to produce this incorrect behavior on all SDK version 3.0, on the iPhone simulator, and on a iPhone 3G and iPhone 3GS. When the button type is of rounded rect the animation works as expected. This issue only pertains to buttons of the custom type.

Notes:
Current workaround is to subclass UIViews and handle touch events manually instead of using a UIButton. This leads to a lot more work to mimic fully the behavior of a UIButton.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!