0

I am trying to animate the opacity of a CALayer but the values are more than one value to begin with and one to end with.

For example: I want it to animate throw these values: 0.0, 0.7, 0.3, 1.0, 0.5, 0.0

I also want the animation to repeat with auto reverse. This is what I have for now:

let redLineAnimation = CABasicAnimation(keyPath: "opacity") redLineAnimation.duration = 0.4 redLineAnimation.autoreverses = true redLineAnimation.fromValue = 0.0 redLineAnimation.toValue = 1.0 redLineAnimation.repeatCount = Float.infinity movingRedLineLayer.addAnimation(redLineAnimation, forKey: nil) 

I am new to iOS development. What can I do? Thanks!

1

1 Answer 1

1

Take a look at CAKeyframeAnimation. That will give you what you want.

And if what you are animating is a view's layer, you could use the easier-to-use UIView keyframe based animation methods. (Core Animation is pretty tricky, and the docs are spotty)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.