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.
Asked
Active
Viewed 123 times
1
-
you can use GradualLayer. – aircraft Feb 02 '17 at 00:55
-
What's GradualLayer? – Faisal Syed Feb 02 '17 at 00:58
-
@Faisai Syed https://developer.apple.com/reference/quartzcore/cagradientlayer – aircraft Feb 02 '17 at 01:03
-
That should be `CAGradientLayer`, not `GradualLayer`. – Duncan C Feb 02 '17 at 01:07
1 Answers
0
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?