THCircularProgressViewiOS 圆形进度条

联合创作 · 2023-09-26 13:22

THCircularProgressView 是一个 iOS 的圆形的进度条。

用法

THCircularProgressView只是一个UIView子类,因此只需实例化它,然后将其添加为视图层次结构。初始化程序是:

- (instancetype)initWithCenter:(CGPoint)center
              radius:(CGFloat)radius
           lineWidth:(CGFloat)lineWidth
        progressMode:(THProgressMode)progressMode
       progressColor:(UIColor *)progressColor
progressBackgroundMode:(THProgressBackgroundMode)backgroundMode
progressBackgroundColor:(UIColor *)progressBackgroundColor
          percentage:(CGFloat)percentage

您也可以使用标准-[UIView initWithFrame:(CGRect)frame]

它支持两种进度模式:

  • THProgressModeFill-开始为空,并随着百分比的增加而被填充;(默认)
  • THProgressModeDeplete -开始充满并随着百分比的增加而耗尽;

还可以设置一个标签,以显示进度视图表示的数字。例如:

THCircularProgressView *progress = ...;
CGFloat percentage = 0.3f;
progress.centerLabel.text = [NSString stringWithFormat:@"%.0f", percentage * 100.0f];
progress.centerLabelVisible = YES; // needed since label is invisible by default

其中的示例项目/Demo包含一些示例。

浏览 1
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报