转自:http://blog.csdn.net/trandy/article/details/6626281
- -(UIImageView *) makeRotation:(UIImageView *)image speedX:(float)X speedY:(float)Y
- {
- // 头文件中需要定义 PI
- // #define PI 3.14159265358979323846264338327950288
- if (Y<0) {
- image.transform = CGAffineTransformMakeRotation(atan(X/(-Y)));
- }else if(Y>0){
- image.transform = CGAffineTransformMakeRotation(atanf(X/(-Y))-PI);
- }
- return image;
- }