[objective-c]NSViewのフェード

NSViewのフェード

view.wantsLayer = YES;
view.hidden = NO;
view.layer.opacity = 1.0;
CABasicAnimation * alphaAnimation  = [CABasicAnimation animationWithKeyPath:@"opacity"];
alphaAnimation.removedOnCompletion =  YES;
alphaAnimation.autoreverses = NO;
alphaAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
alphaAnimation.duration = fadeDuration_;
alphaAnimation.fromValue = [NSNumber numberWithFloat:0.0];
alphaAnimation.toValue = [NSNumber numberWithFloat:1.0];
alphaAnimation.byValue = [NSNumber numberWithFloat:1.0];
[view.layer addAnimation:alphaAnimation forKey:@"opacityAnimation"];