动画CALayer隐藏 [英] Animate CALayer hide

查看:116
本文介绍了动画CALayer隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在几微秒后隐藏 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆