我需要在 iphone sdk interface builder 中将按钮旋转 30 度,你是怎么做的?
Brian
问问题
8075 次
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 回答