2012-08-10 2 views
0

이 코드가 10.6 및 10.7에서 잘 작동하는 이유는 정말 혼란 스럽지만 10.8에서는 애니메이션이없고 불투명도 값이 즉시 변경됩니다. Self는 NSView 하위 클래스입니다. Mountain Lion에서 레이어 불투명도의 애니메이션이 움직이지 않습니다

[CATransaction begin]; 
[CATransaction setValue:[NSNumber numberWithFloat:0.5] 
       forKey:kCATransactionAnimationDuration]; 
self.layer.opacity = 1.0; 
self.labelFilename.layer.opacity = 1.0; 
self.labelDate.layer.opacity = 1.0; 
[CATransaction commit]; 

는 반대로이 코드는 10.6에 애니메이션 실패하지만, 10.7 및 10.8

CABasicAnimation *theAnimation; 
theAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 
theAnimation.duration = 0.5; 
theAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; 
theAnimation.toValue=[NSNumber numberWithFloat:1.0]; 
theAnimation.removedOnCompletion = NO; 
theAnimation.fillMode = kCAFillModeForwards; 
[self.layer addAnimation:theAnimation forKey:@"fadeUp"]; 
[self.labelFilename.layer addAnimation:theAnimation forKey:@"fadeUpName"]; 
[self.labelDate.layer addAnimation:theAnimation forKey:@"fadeUpDate"]; 
+0

저는 비슷한 문제가 있습니다. 이 문제의 원인을 파악할 수 있었습니까? – Martin

+0

10.8에서 CAAnimation과 유사한 문제가 있습니다 (예 : http://stackoverflow.com/questions/13307632/nsimageview-layer-not-updating-before-during-animation). 이 문제에 대한 진전 사항은 무엇입니까? – thumbsup

답변

0

에 잘 작동 난 내 애니메이션과 같이, 명시 적 애니메이션을 추가하여 10.8에서 작동하도록 돌아왔다 :

// added explicit animation 
CABasicAnimation *animOut = [CABasicAnimation animationWithKeyPath:@"transform"]; 
CATransform3D transform = CATransform3DMakeRotation(pi,0,1,0); 
transform = CATransform3DScale(transform, scaleFactor, scaleFactor, 1.0f); 
[animOut setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]]; 
[animOut setToValue:[NSValue valueWithCATransform3D:transform]]; 
[animOut setDuration:0.3f]; 
[[goingImageView layer] addAnimation:animOut forKey:nil]; 

// implicit animation code that worked before 10.8 
[[goingImageView layer] setTransform:transform]; 
관련 문제