Subclass an UIView (maybe CircularProgress : UIView) and draw it manually with Quartz (paths, circles, etc) on the drawRect method passing the % of the progress as it changes.
You can check my code and make something more appropriated. In my scenario, I'm drawing once and then I just rotate the image/layer. You'll need to animate the strokeEnd property using something like CABasicAnimation.
This property is animated and if you increase it from 0 to 1, you'll get the "filling effect". Again, in my scenario I need the empty center, probably you won't need it, your line width will be larger.
发布评论
评论(2)
子类化一个 UIView(可能是 CircularProgress : UIView)并使用 Quartz 手动绘制它(路径、圆圈等),并在 drawRect 方法上手动绘制它,并在变化时传递进度的 %。
Subclass an UIView (maybe CircularProgress : UIView) and draw it manually with Quartz (paths, circles, etc) on the drawRect method passing the % of the progress as it changes.
我在这里做类似的事情: https://github.com/DougFischer/DFCircleActivityIndicator
你可以检查我的编码并做出更合适的东西。在我的场景中,我绘制一次,然后旋转图像/图层。您需要使用诸如 CABasicAnimation 之类的方法来为 strokeEnd 属性设置动画。
该属性是动画的,如果将其从 0 增加到 1,您将获得“填充效果”。同样,在我的场景中,我需要空的中心,可能你不需要它,你的线宽会更大。
I'm doing something similar here: https://github.com/DougFischer/DFCircleActivityIndicator
You can check my code and make something more appropriated. In my scenario, I'm drawing once and then I just rotate the image/layer. You'll need to animate the strokeEnd property using something like CABasicAnimation.
This property is animated and if you increase it from 0 to 1, you'll get the "filling effect". Again, in my scenario I need the empty center, probably you won't need it, your line width will be larger.