[英]Animating CALayer in IKImageBrowserCell
我有一個帶有IKImageBrowserCell子類的自定義圖像瀏覽器視圖,其中我添加了一個我想在某些場合制作動畫的小符號圖形。
它有點像Panic的Coda Sites視圖上的“我”標志(我猜測它是一個定制的ImageBrowserView對吧?)。 在Coda的網站視圖中,如果你將鼠標懸停在一個項目上,那么當你徘徊時我就會消失並消失。
試圖重現這種效果,我正在努力。
我已經將IKImageBrowserCell子類化了,我在layerForType期間保存了對符號圖層的引用。
然后當鼠標移過時我試圖改變不透明度,但它沒有改變。
懸浮檢測代碼本身可以工作,我從NSLogs知道,但CALayer的隱式動畫(signLayer.opacity = 1.0)從未啟動過。
有什么建議嗎?
也許我錯過了一些東西(有點像Core Animation的新手)。
謝謝
嘗試這個:
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"];
要淡入圖層,請使用twoValue切換fromValue並重命名該鍵。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.