核心动画不起作用。物体消失
[animationImageView setWantsLayer:YES];
CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframeAnimation.values = [animationsBindingsController valueForKeyPath:@"selection.controlPoints"];
keyframeAnimation.duration = 5;
[animationImageView.layer addAnimation:keyframeAnimation forKey:@"position"];
[pageContent addSubview:animationImageView];
AnimationImageView
是 NSImageView
的子类。
animationImageView
对象消失 5 秒(动画持续时间),然后突然出现在初始位置。
[animationImageView setWantsLayer:YES];
CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframeAnimation.values = [animationsBindingsController valueForKeyPath:@"selection.controlPoints"];
keyframeAnimation.duration = 5;
[animationImageView.layer addAnimation:keyframeAnimation forKey:@"position"];
[pageContent addSubview:animationImageView];
AnimationImageView
is a subclass of NSImageView
.
animationImageView
object disappears for a 5 seconds (for a duration of animation), and suddenly it appears in init position.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我没有子类化 NSImageView,而是子类化 CALayer(通过方法 setContents:你可以设置 NSImage)。核心动画完美运行!
Ok, Instead of subclassing NSImageView, I subclassed CALayer (by method setContents: you can set NSImage). Core Animation works perfectly!