iPhone 圆形进度指示器

发布于 2024-09-02 08:42:57 字数 1436 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叹沉浮 2024-09-09 08:42:57

子类化一个 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.

灯角 2024-09-09 08:42:57

我在这里做类似的事情: https://github.com/DougFischer/DFCircleActivityIndi​​cator

你可以检查我的编码并做出更合适的东西。在我的场景中,我绘制一次,然后旋转图像/图层。您需要使用诸如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文