2012-08-13 3 views
1

는 내가있는 CALayer의 애니메이션 그림자 경로가 :코어 애니메이션 : 확인 내용 다음과 그림자 경로

CABasicAnimation* shadowAnimation = [CABasicAnimation animationWithKeyPath: @"shadowPath"]; 
shadowAnimation.duration = duration; 
shadowAnimation.timingFunction = function; 
shadowAnimation.fromValue = (id) panelView.layer.shadowPath; 

panelView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect: CGRectSetOriginM20 (panelView.bounds, CGPointZero) cornerRadius: cornerRadius].CGPath; 
[panelView.layer addAnimation: shadowAnimation forKey: @"shadow"]; 
panelView.layer.shadowOpacity = 1.0; 

내가있는 UIImage로 설정하여있는 CALayer의 컨텐츠 속성을 자산을 사용하여 동일한 효과를 다시 만들어야합니다. bounds을 그림자와 동일한 애니메이션을 따르도록 할 수있는 방법이 있습니까?

답변

1

아니요, 콘텐츠를 섀도우 경로를 따라 만들 수 없습니다.

그림자 경로와 경계를 함께 애니메이션화해야합니다. 이 작업은 애니메이션 그룹에서 수행 할 수 있으므로 그룹의 타이밍 기능과 기간 만 구성 할 수 있습니다.

CAAnimationGroup* shadowAndBounds = [CAAnimationGroup animation]; 
shadowAndBounds.duration = duration; 
shadowAndBounds.timingFunction = function; 

CABasicAnimation* shadowAnimation = [CABasicAnimation animationWithKeyPath: @"shadowPath"]; 
// Set to and from value for the shadow path ... 

CABasicAnimation* boundsAnimation = [CABasicAnimation animationWithKeyPath: @"bounds"]; 
// Set to and from value for the bounds ... 

shadowAndBounds.animations = @[ shadowAnimation, boundsAnimation ]; 
[panelView.layer addAnimation: shadowAndBounds forKey: @"shadowAndBounds"]; 
관련 문제