Brandon
Brandon

Reputation: 3136

Animate a line into a sine wave in iOS

I'm new to animation in iOS and there seems to be a lot of different ways to accomplish the same thing. I'm looking for a way to animate a flat line into a sine wave and back. What would be the best way to accomplish this? Also how would I go about adding an ease out or bounce effect?

Upvotes: 0

Views: 2139

Answers (1)

Wain
Wain

Reputation: 119031

You can use a combination of CAShapeLayer (with UIBezierPaths to specify your line and sine wave line) and CABasicAnimation to achieve this:

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"path"];
animation.fromValue = (id)linePath;
animation.toValue = (id)sinePath;
[shapeLayer addAnimation:animation forKey:@"animatePath"];

Upvotes: 2

Related Questions