Faisal Syed
Faisal Syed

Reputation: 931

How to Change Color of UIBezierPath Stroke Whilst Animating?

I was wondering if it was possible to change the color of a UIBezierPath strokeColor while its animating. For instance, if it goes past a certain angle like 45 deg, it changes from green to orange, and if it goes past 66 deg it goes from orange to red.

Upvotes: 1

Views: 136

Answers (1)

Duncan C
Duncan C

Reputation: 131418

Somebody else suggested using a "gradual" (gradient) layer. If you can create a gradient that meets your needs then that would work.

You could do just about anything you want by creating an image that contains the colors you want, and then installing a shape layer as a mask layer to that image's layer, and animating changes to the path installed in the shape layer.

I've used a technique like that to create various sorts of "wipe" transitions that reveal an image. See the thread below for info and working code showing how to create a "Clock wipe", which is almost exactly what you need:

How do you achieve a "clock wipe"/ radial wipe effect in iOS?

Upvotes: 0

Related Questions