1
A
回答
0
使用CGAffineTransformMakeRotation()
为按钮的transform
属性设置动画效果,并将其与NSTimer
以随机时间间隔相结合。
0
#define RADIANS(degrees) ((degrees * M_PI)/180.0)
CGAffineTransform rotateTransform = CGAffineTransformRotate(CGAffineTransformIdentity,
RADIANS(30.0));
myButton.transform = rotateTransform;
使用NSTimer进行此过程并使用arc4random随机生成弧度角。
+0
此代码将在同一原点旋转按钮。我想在320 * 480视图中旋转按钮。 – Tariq 2011-05-24 10:52:52
1
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];
也看看这个链接是对你有用:Moving UIButton
相关问题
- 1. iPhone屏幕随机旋转?
- 2. android.view.InflateException在屏幕上旋转
- 3. 旋转屏幕
- 4. 屏幕旋转
- 5. 屏幕旋转
- 6. 屏幕旋转
- 7. 屏幕旋转
- 8. 在Android手机上重新排列UI在屏幕旋转上
- 9. 在屏幕上移动UIbutton
- 10. 在Android上禁用屏幕旋转
- 11. 禁用屏幕旋转在Android如上
- 12. 在屏幕上旋转矩形
- 13. 在整个屏幕上旋转图像
- 14. 在屏幕上保存MediaPlayer旋转
- 15. 画廊在屏幕上重置旋转
- 16. 保持对象在屏幕上旋转?
- 17. 旋转和翻译UIImageView在屏幕上
- 18. TextView消失在屏幕上旋转
- 19. 随机移动星星在屏幕上
- 20. 旋转屏幕TableLayout
- 21. iPhone - 屏幕旋转?
- 22. iOS屏幕旋转
- 23. 当屏幕旋转
- 24. 使用jQuery/javascript旋转手机屏幕
- 25. nullPointerException在屏幕旋转后
- 26. Windows 10手机旋转屏幕/屏幕方向
- 27. 当我旋转手机时,活动屏幕不旋转
- 28. 的Android旋转器旋转屏幕
- 29. Android上的简单屏幕旋转
- 30. Pocket PC上的屏幕旋转
如果我将使用arc4random按钮,然后旋转会干,我怎么能使其在320 * 480的视图旋转平稳? – Tariq 2011-05-24 10:53:50