2012-08-27 4 views
0

나는 다음과 같은 애니메이션을 구현하기 위해 노력하고있어 : 하위 뷰의 일부 움직임과 결합UIView의 그룹 애니메이션

yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01); 
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 
//change time duration according to requirement 
// animate it to the identity transform (100% scale) 
yourSubView.transform = CGAffineTransformIdentity; 
} completion:^(BOOL finished){ 
// if you want to do something once the animation finishes, put it here 
}]; 

. 핵심 애니메이션에서 애니메이션을 결합 할 수 있지만 UIView 애니메이션에서 어떻게 할 수 있습니까?

이 코드를 UIView 애니메이션에서 Core 애니메이션으로 변환 할 수 있습니까?

yourSubView.transform = CGAffineTransformMakeScale(0.01, 0.01); 
[UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 
//change time duration according to requirement 
// animate it to the identity transform (100% scale) 
yourSubView.transform = CGAffineTransformIdentity; 
} completion:^(BOOL finished){ 
// if you want to do something once the animation finishes, put it here 
}]; 

답변

2

두 개 이상의 애니메이션 가능 속성을 변경하여 애니메이션을 결합 할 수 있습니다. 예를 들어, YourSubView.alpha를 설정 한 다음 애니메이션 블록 내에서 알파를 변경할 수도 있습니다. 스케일과 알파 변경을 결합합니다.

간단한 번역 작업을 수행하려면, 애니메이션 블록에서 이것을 시도 :

yourSubView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 100.0, 100.0); 

이 x와 y 방향으로 100 픽셀 이동과 함께 다시 정체성 규모를 설정해야합니다.

코어 애니메이션의 경우이 Grouping two Core Animations with CAAnimationGroup causes one CABasicAnimation to not run을 시작해야합니다. CAAnimationGroup을 사용하여 여러 애니메이션을 결합하고 3D 로테이션을 포함한 멋진 작업을 수행 할 수 있습니다.

배율 :

코어 애니메이션 코드를 변환하는 방법
CAKeyframeAnimation *scale = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; 
[scale setValues:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.01f],[NSNumber numberWithFloat:1.0f],nil]]; 
[scale setKeyTimes:[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.4f],nil]]; 

[mySubview.layer addAnimation:scale forKey:@"myScale"]; 
+0

: yourSubView.transform CGAffineTransformMakeScale = (0.01, 0.01); [UIView animateWithDuration : 0.4 지연 : 0 옵션 : UIViewAnimationOptionCurveEaseOut 애니메이션 :^{ // 요구 사항에 따라 기간 변경 // IDT (100 % 눈금)로 애니메이션 적용 yourSubView.transform = CGAffineTransformIdentity; } 완료 :^(BOOL 완료) { // 일단 애니메이션이 끝나면 무언가를하고 싶다면 여기에 넣으십시오. }]; – Juan

+0

수정 된 답변은 스케일링 예제를 보여줍니다 – CSmith

관련 문제