2012-08-13 1 views
0

단추를 누르거나 작업을 완료 할 때 약간의 신축성을 & 기울이기 애니메이션 UIView으로 줄 필요가 있습니다.플래시/깜박임 UIView

UIView에 적용된 대부분의 애니메이션은 일반적으로 UIView에 추가되거나 제거 될 때 적용되지만보기에 이미 추가 된보기를 통해 어떻게 수행 할 수 있습니까?

애니메이션은 사용자의주의를 끌기 만하면됩니다 (작업이 완료되었음을 나타냄).

+0

그래서 스트레칭과 비뚤어 짐 또는 플래시입니까? –

+0

어떤 애니메이션이 되겠습니까 :) – tGilani

답변

1

사용 코어 애니메이션이 필요하고 그룹 모두에서 애니메이션을 추가 할 수 있습니다How to scale and rotate a view in a single animation

편집 :

CABasicAnimation *stetchAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"]; 
stetchAnimation.toValue = [NSNumber numberWithDouble:(someView.frame.size.width+100)/someView.frame.size.width]; 

CABasicAnimation *skewAnimation = CABasicAnimation animationWithKeyPath:@"transform.rotation.x"]; 
stetchAnimation.toValue:[NSNumber numberWithInt:180]; 

//Add both animation at time when task is completed 

CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 
animationGroup.animations = [NSArray arrayWithObjects:stetchAnimation,skewAnimation,nil]; 
animationGroup.removedOnCompletion = YES; 
animationGroup.fillMode = kCAFillModeForwards; 
animationGroup.duration = 0.7; // increase duration if needed 

[someView.layer addAnimation:animationGroup forKey:@"animations"]; 
+0

마지막 줄이 실행될 때 (즉, 애니메이션이 레이어에 추가 될 때) 애니메이션이 시작되거나 너무 다른 것을해야합니까? – tGilani

+0

예 애니메이션이 시작됩니다 –

+0

http://stackoverflow.com/questions/9341332/how-to-scale-and-rotate-a-view-in-a-single-animation –

1

간단한 UIView의 애니메이션; 보기를 일시적으로 확장시킵니다.

[UIView animateWithDuration:0.3 animations:^{ 
    CGRect frm = view.frame; 
    frm.size.width += 20; 
    frm.size.height += 20; 
    frm.origin.x -= 10; 
    frm.origin.y -= 10; 
    view.frame = frm; 
} completion:^{ 
    [UIView animateWithDuration:0.3 animations:^{ 
     CGRect frm = view.frame; 
     frm.size.width -= 20; 
     frm.size.height -= 20; 
     frm.origin.x += 10; 
     frm.origin.y += 10; 
     view.frame = frm; 
    }]; 
}];