Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale/Rotate a button in interface

I need to rotate a button by 30 degrees in iphones sdk interface builder, how do you do that?


1 Answers

You can't do it in Interface Builder, but the code is pretty straightforward.

Make sure you've connected the button in IB to an IBOutlet of type UIButton* (let's call it myButton). Then once the nib has been loaded (for example, in your viewDidLoad method) you can use something like this:

#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

CGAffineTransform rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity,
         RADIANS(30.0));

myButton.transform = rotateTransform;
like image 60
Ramin Avatar answered Dec 31 '25 14:12

Ramin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!