我有一个自定义的带有IKImageBrowserCell子类的图像浏览器视图,我在其中添加了一个小的标志图形,我想在某些情况下将其动画化。
它有点像Panic的Coda Sites视图上的"i“符号(我猜这是一个ImageBrowserView定制的.对吧?)。在Coda的网站视图上,如果你在一个项目上悬停,当你悬停在外面时,我会淡入并消失。
试图重现这种效果,而我正在努力。
我已经创建了IKImageBrowserCell的子类,并且在layerForType期间保存了对符号图层的引用。
然后,当鼠标经过时,我试图改变不透明度,但它没有改变。
我从NSLogs得知,悬停检测代码本身可以工作,但CALayer (signLayer.opacity = 1.0)的隐式动画永远不会起作用。
有什么建议吗?
也许我错过了一些东西(对Core Animation来说有点陌生)。
谢谢
发布于 2010-10-22 05:03:31
试试这个:
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration = 0.8s //the duration of the fade
animation.repeatCount = 0;
animation.autoreverses = NO;
animation.fromValue = [NSNumber numberWithFloat:1.0];
animation.toValue = [NSNumber numberWithFloat:0.0];
[myLayer addAnimation:animation forKey@"fadeOut"];要淡入图层,请将fromValue切换为twoValue并重命名该索引。
希望这能有所帮助。
https://stackoverflow.com/questions/3928759
复制相似问题