CALayer opacity animation

前端 未结 2 920

I want to create a CALayer animation that gives sort of a \'flashy\' effect. For that I\'m trying to animate the \'opacity\' property, but my problem is that I have no idea wher

2条回答
  •  面向向阳花
    2021-02-07 04:09

    Trojanfoe's answer is excellent. I just want to add that if you want more control over the "timeline" (how long should it take to fade out? how long should we then wait? then how long should it take to fade in? and so on) you're going to want to combine multiple CABasicAnimations into a CAAnimationGroup.

    You might want to read my book chapter on this topic, the last part of which constitutes a tutorial on CAAnimation and its offspring:

    http://www.apeth.com/iOSBook/ch17.html#_core_animation

    Note that my discussion is directed at iOS; on Mac OS X, if that's where you are, the view/layer architecture is a little different, but what it says about CAAnimation is still correct.

提交回复
热议问题