I am trying to build an animated pie chart that can animate the pie in both directions depending on whether the value of its progress
increases or decreases. I\'ve
The code in the answer you posted (animated CAShapeLayer pie) works fine in both directions for me, even using clearColor
: see this video.
The only situation in which clearColor
does not produce a correct behavior is when the background color is solid and the foreground is clear: in that case a change in the blending mode is required, as you pointed out in your code.
I tried with these three configuration, and in all the cases the layer was responding correctly to -setProgress:
.
DZRoundProgressView
as subview of the main UIView
;DZRoundProgressView
;DZRoundProgressView
as sublayer of the main UIView
;Moreover, it is unlikely that the content of a layer in the previous frame is still visible at the next draw call: apparently, the default behavior of -drawInContext:
is to clear the context before execution, as this question says.
If you are not working with the contents
property of the layer, and you are not hacking the drawing pipe, then there could be something wrong with the value of self.progress
; perhaps some issue with presentation layer and model layer, or in the implementation of the property.
Indeed this doesn't solve your problem, since I couldn't reproduce it or isolate it, but should allow you to work around it.