In my iOS 7 project (using XCode 5) I define a custom MyButton class which derives from UIButton and sets the background image in the drawRect method:
- (void)drawRect:(CGRect)rect
{
[self setBackgroundImage:[UIImage imageNamed:@"redButton.png"] forState:UIControlStateNormal];
}
My main view controller contains a view with an instance of MyButton (specified in IB) with a width and height of 100.
In the viewDidLoad method I am applying a rotation transform:
self.myButton.transform = CGAffineTransformMakeRotation( 45.0/180*M_PI );
which correctly rotates the button by 45 degrees. However, it also shrinks the button so that the button fits within the original 100x100 box!
What do I need to do either to the MyButton class (preferred) or the owning view so that the size of the button is not diminished?
I tried setting the clipToBounds property on both the MyButton class as well as the view but to no avail.