ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 이미지 회전
    backup/iOS 2011. 9. 1. 11:01
    #define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI)


    - (void)rotateImage:(UIImageView *)image duration:(NSTimeInterval)duration 
           curve:(int)curve degrees:(CGFloat)degrees
    {
      // Setup the animation
      [UIView beginAnimations:nil context:NULL];
      [UIView setAnimationDuration:duration];
      [UIView setAnimationCurve:curve];
      [UIView setAnimationBeginsFromCurrentState:YES];
     
      // The transform matrix
      CGAffineTransform transform = 
          CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
      image.transform = transform;
     
      // Commit the changes
      [UIView commitAnimations];
    }


    - (void)startApp
    {
      UIImageView *imageToMove =
         [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ArrowUp.png"]];
      imageToMove.frame = CGRectMake(10, 10, 20, 100);
      [self.view addSubview:imageToMove];
     
      [self rotateImage:imageToMove duration:3.0 
          curve:UIViewAnimationCurveEaseIn degrees:180];
     
      ...
     
    
    }
     
Designed by Tistory.