CALayer animation in IKImageBrowserCell

I have a custom image browser view with a subclass of IKImageBrowserCell, where I added a little graphics that I would like to animate in some cases.

Is this similar to the β€œi” sign in the Panic Coda Sites view (which I assume is a custom ImageBrowserView ..)? On Coda site views, if you hover over a project, I fade out a bit and leave when you hover over.

Trying to reproduce this effect, and I'm afraid.

I have subclassed IKImageBrowserCell and I keep the reference to the sign layer during layerForType ..

Then, when the mouse goes, I try to change the opacity, but it does not change.

The guidance detection code itself works, I know from NSLogs, but the implicit CALayer animation (signLayer.opacity = 1.0) never fires.

Any suggestion?

Maybe I missed something (new to Core Animation).

thanks

+4
source share
1 answer

Try the following:

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"]; 

To fade out a layer, switch fromValue with two values ​​and rename the key.

Hope this helps.

0
source

All Articles