3

我需要在 iphone sdk interface builder 中将按钮旋转 30 度,你是怎么做的?

4

3 回答 3

11

您不能在 Interface Builder 中执行此操作,但代码非常简单。

确保您已将 IB 中的按钮连接到IBOutlet类型UIButton*(我们称之为myButton)。然后一旦 nib 被加载(例如,在你的viewDidLoad方法中)你可以使用这样的东西:

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

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

myButton.transform = rotateTransform;
于 2009-07-29T21:18:49.320 回答
0

我不确定您是否可以直接执行此操作。如果您通过 CoreGraphics 图层绘制自己的按钮,您也许可以做到这一点。

核心动画层

于 2009-07-29T20:02:30.377 回答
-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];
于 2009-07-29T22:21:22.227 回答