0

I'm really confused why this code works fine on 10.6 and 10.7, but on 10.8 there is no animation and the opacity value changes immediately. Self is a NSView subclass.

[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];

Conversely this code fails to animate on 10.6 but works fine on 10.7 and 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"];
4

1 に答える 1

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];
于 2012-11-09T13:41:21.897 に答える