随意在屏幕上旋转UIButton

| 我想在屏幕上随机旋转按钮。没有定义的特定路径可以在视图上随机移动。 我不想使用CAKeyframeAnimation。它应该干净简单。 谁能指导我?     
已邀请:
使用
CGAffineTransformMakeRotation()
对按钮的
transform
属性进行动画处理,并将其与带有随机时间间隔的
NSTimer
组合。     
CGAffineTransform cachedTransform = transformedView.transform;
transformedView.transform = CGAffineTransformIdentity;

// Note each of the (untransformed) points of interest.
CGPoint topLeft = CGPointMake(0, 0);
CGPoint bottomLeft = CGPointMake(0, transformedView.frame.size.height);
CGPoint bottomRight = CGPointMake(transformedView.frame.size.width, transformedView.frame.size.height);
CGPoint topRight = CGPointMake(transformedView.frame.size.width, 0);

// Re-apply the transform.
transformedView.transform = cachedTransform;

// Use handy built-in UIView methods to convert the points.
topLeft = [transformedView convertPoint:topLeft toView:parentView];
bottomLeft = [transformedView convertPoint:bottomLeft toView:parentView];
bottomRight = [transformedView convertPoint:bottomRight toView:parentView];
topRight = [transformedView convertPoint:topRight toView:parentView];
另请参阅此链接是否对您有用:移动UIButton     
#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

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

myButton.transform = rotateTransform;
使用NSTimer进行此过程,并使用arc4random随机生成弧度角。     

要回复问题请先登录注册