Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does fillMode do exactly?

The documentation is not talking really much about what this technically does.

fadeInAnimation.fillMode = kCAFillModeForwards;

I don't really see the effect of this. I have an view with alpha set to 0.0. Then I fade it in. But when I uncomment the line abouth, nothing changes. Same behavior. I'd like to understand what this fillMode really does.

like image 764
Thanks Avatar asked Jul 22 '09 17:07

Thanks


2 Answers

From the CAMediaTiming protocol documentation:

Determines if the receiver’s presentation is frozen or removed once its active duration has completed.

This determines what happens at the end of your animation. By default, it is set to kCAFillModeRemoved, which means that the animation changes are undone when the animation is completed. If you switch it to kCAFillModeForwards, the changes caused by the animation will hang around.

Note that you will also probably need to set the removedOnCompletion property to NO to prevent your animation from being removed, which would make this setting ineffective.

like image 198
Brad Larson Avatar answered Oct 24 '22 14:10

Brad Larson


let me give it a more clarified answer:
although in appearance setting the animation’s fillMode property to kCAFillModeForwards(or kCAFillModeBoth) and at the same time setting removedOnCompletion to NO can keep your layer in its final status when animation finished but this use of fillMode is not the designed way. and actually do harm if you have other animation add to the same the keyPath

(by the way,the correct approach for keep animation final state is to change the property value to match the final frame of the animation.)

what the fillMode really use is in connection with a child animation within a grouped animation so you can specify specific child animation in desired state

like image 31
dispute Avatar answered Oct 24 '22 16:10

dispute