简体   繁体   中英

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM