Animated pie chart that can animate in both directions

馋奶兔 提交于 2019-12-02 13:31:29
Pietro Saccardi

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;
  • Class of main view set to 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!