动画CALayer隐藏 [英] Animate CALayer hide
问题描述
我试图在几微秒后隐藏 CALayer
,并且使用 CABasicAnimation
为隐藏。
此刻我正在尝试使用
[aLayer setHidden:YES];
CABasicAnimation * hideAnimation = [CABasicAnimation animationWithKeyPath:@ hidden];
[hideAnimation setDuration:aDuration];
[hideAnimation setFromValue:[NSNumber numberWithBool:NO]];
[hideAnimation setToValue:[NSNumber numberWithBool:YES]];
[hideAnimation setBeginTime:0.09];
[hideAnimation setRemovedOnCompletion:NO];
[hideAnimation setDelegate:self];
[alayer addAnimation:hideAnimation forKey:@ hide];
但是当我运行此命令时,该层将立即隐藏,而不是等待所需的beginTime。 / p>
我不确定我的keyPath是否为隐藏,但找不到其他选择,并且文档中确实指出了隐藏$
CALayer
的c $ c>属性是可动画的。
实现我所期待的正确方法是什么
请尝试设置opacity属性的动画。从1.0更改为0.0,您应该会得到想要的效果。
I'm trying to hide a CALayer
after a few microseconds and I'm using CABasicAnimation
to animate the hide.
At the moment I'm trying to use
[aLayer setHidden:YES];
CABasicAnimation * hideAnimation = [CABasicAnimation animationWithKeyPath:@"hidden"];
[hideAnimation setDuration:aDuration];
[hideAnimation setFromValue:[NSNumber numberWithBool:NO]];
[hideAnimation setToValue:[NSNumber numberWithBool:YES]];
[hideAnimation setBeginTime:0.09];
[hideAnimation setRemovedOnCompletion:NO];
[hideAnimation setDelegate:self];
[alayer addAnimation:hideAnimation forKey:@"hide"];
But when I run this, the layer is hidden immediately, rather than waiting for the desired beginTime.
I'm uncertain about my keyPath as "hidden" but couldn't find any other option and the documentation does state that the hidden
property of a CALayer
is animatable.
What's the correct way to achieve what I'm looking for?
Try animating the opacity property instead. Go from 1.0 to 0.0 and you should get the effect you want.
这篇关于动画CALayer隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!