3

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

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
  • possible duplicate of [How can I rotate an UIImageView in Interface Builder?](http://stackoverflow.com/questions/14654096/how-can-i-rotate-an-uiimageview-in-interface-builder) – Gabriele Sep 03 '15 at 15:12

3 Answers3

11

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;
Ramin
  • 13,343
  • 3
  • 33
  • 35
0

I'm not sure that you can do it directly. You might be able to do it if you were drawing your own buttons via CoreGraphics layers.

Core Animation Layers

AlBlue
  • 23,254
  • 14
  • 71
  • 91
-1
             [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:0.5];

    button.transform=CGAffineTransformMakeRotation((0.0174532925)*30);

    //put the -ve sign before 30 if you want to rotate the button in the anticlockwise else use this one 

    [UIView commitAnimations];