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

时间:2023-02-15 23:49:13

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

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