How to rotate the imageView in a UIButton, and NOT scale it

Viewed 10351

I am endeavouring to rotate the imageView property of a UIBUtton without scaling it. The image in question is 24x18 - wider than it is tall - but once rotated into place the image is being scaled to keep those dimension - leaving me with a very squished image. How can I prevent this?

Below is my code ..

-(IBAction)rotateButton
{
NSLog( @"Rotating button" );

[UIView beginAnimations:@"rotate" context:nil];
[UIView setAnimationDuration:.5f];
if( CGAffineTransformEqualToTransform( button.imageView.transform, CGAffineTransformIdentity ) )
{
    button.imageView.transform = CGAffineTransformMakeRotation(M_PI/2);
} else {
    button.imageView.transform = CGAffineTransformIdentity;
}
[UIView commitAnimations];
}

This doesn't happen if I apply the transform to the button instead of button.imageView, so I'm guessing it's a property of imageView that I'm not setting right.

Your clues & boos are most welcome

M.

3 Answers
Related