UIImageView旋转任意角度---实现方法

时间:2021-04-12 17:34:10

 

转自:http://blog.csdn.net/trandy/article/details/6626281

  1. -(UIImageView *) makeRotation:(UIImageView *)image speedX:(float)X speedY:(float)Y  
  2. {  
  3.       
  4. //    头文件中需要定义 PI  
  5. //    #define PI 3.14159265358979323846264338327950288  
  6.       
  7.     if (Y<0) {  
  8.         image.transform = CGAffineTransformMakeRotation(atan(X/(-Y)));  
  9.     }else if(Y>0){  
  10.         image.transform = CGAffineTransformMakeRotation(atanf(X/(-Y))-PI);   
  11.     }  
  12.     return image;