2012-03-01 5 views
1

메일 앱이 다른 상자로 이메일 메시지를 이동하려고 할 때 "봉투"아이콘이 날아 다니는 것처럼 이미지에 애니메이션을 적용하고 싶습니다. CoreAnimation을 사용하려고했지만 곡선 경로를 따라야합니다.iPhone의 이메일 앱처럼 이미지 애니메이션하기

누군가가 그 방법을 가르쳐 줄 수 있습니까?

답변

7

UIBeizerPath는 애니메이션 중에 imageObject의 경로를 만드는 데 사용할 수있는 클래스입니다.

아이폰에서 이미지 삭제 애니메이션처럼 만든이 애니메이션을 시도해보십시오.

- (IBAction)buttonClicked:(id)sender { 
    UIView *senderView = (UIView*)sender; 
    if (![senderView isKindOfClass:[UIView class]]) 
     return; 

    UIView *icon =myImageView; 

    //move along the path 
    UIBezierPath *movePath = [UIBezierPath bezierPath]; 
    [movePath moveToPoint:icon.center]; 
    [movePath addQuadCurveToPoint:senderView.center 
        controlPoint:CGPointMake(senderView.center.x, icon.center.y)]; 

    CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
    moveAnim.path = movePath.CGPath; 
    moveAnim.removedOnCompletion = YES; 


    //Scale Animation 
    CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"]; 
    scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; 
    scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1,0.1, 1.0)]; 
    scaleAnim.removedOnCompletion = YES; 


    CAAnimationGroup *animGroup = [CAAnimationGroup animation]; 
    animGroup.animations = [NSArray arrayWithObjects:moveAnim, scaleAnim, nil]; 
    animGroup.duration = 1.0; 
    [icon.layer addAnimation:animGroup forKey:nil]; 

// create timer with time of animation to change the image. 

} 

프로젝트에서 QuartzCore 프레임 워크를 가져 와서 헤더 파일로 가져와야합니다.

관련 문제