Scaling / Rotating the button in the interface

I need to rotate the button 30 degrees in iphones sdk interface builder, how do you do it?

+3
source share
3 answers

You cannot do this in Interface Builder, but the code is pretty simple.

Make sure you connect the button in IB to IBOutlettype UIButton*(call myButton). Then, once the thread has loaded (for example, in your method viewDidLoad), you can use something like this:

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

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

myButton.transform = rotateTransform;
+11
source

I'm not sure if you can do this directly. You could do this if you were drawing your own buttons through CoreGraphics layers.

The main layers of animation

0
             [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];
-1
source

Source: https://habr.com/ru/post/1713893/


All Articles