Skip to content

CircleProgress 环形进度条

介绍

圆环形的进度条组件。

引入

ts
import { IBestCircleProgress } from "@ibestservices/ibest-ui";

代码演示

基础用法

基础用法

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    IBestCircleProgress({
      value: $value,
      text: `${this.value}%`
    })
  }
}

样式定制

样式定制

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    Flex({wrap: FlexWrap.Wrap, space: { main: LengthMetrics.vp(20), cross: LengthMetrics.vp(20) }}){
      IBestCircleProgress({
        value: $value,
        strokeWidth: 6,
        text: "宽度定制"
      })
      IBestCircleProgress({
        value: $value,
        color: "#ee0a24",
        bgColor: "#ebedf0",
        text: "颜色定制"
      })
      IBestCircleProgress({
        value: $value,
        clockwise: false,
        text: "逆时针",
        color: "#07c160"
      })
      IBestCircleProgress({
        value: $value,
        diameter: 120,
        clockwise: false,
        text: "大小定制",
        color: "#7232dd"
      })
    }
  }
}

起始位置

起始位置

点我查看代码
ts
@Entry
@Component
struct DemoPage {
  @State value: number = 30
  build() {
    Flex({wrap: FlexWrap.Wrap, space: { main: LengthMetrics.vp(20), cross: LengthMetrics.vp(20) }}){
      IBestCircleProgress({
        value: $value,
        startPosition: "left",
        text: "左侧"
      })
      IBestCircleProgress({
        value: $value,
        startPosition: "right",
        text: "右侧"
      })
      IBestCircleProgress({
        value: $value,
        startPosition: "bottom",
        text: "底部"
      })
      IBestCircleProgress({
        value: $value,
        startPosition: "left",
        clockwise: false,
        text: "左侧逆时针"
      })
      IBestCircleProgress({
        value: $value,
        startPosition: "right",
        clockwise: false,
        text: "右侧逆时针"
      })
      IBestCircleProgress({
        value: $value,
        startPosition: "bottom",
        clockwise: false,
        text: "底部逆时针"
      })
    }
  }
}

API

@Props

参数说明类型默认值
value进度值, 支持双向绑定number0
diameter进度条直径(宽度)number100
target目标进度number100
text中间文字string''
textColor中间文字颜色ResourceColor#323233
textFontSize中间文字大小number | string16
textFontWeight中间文字字重FontWeight600
color进度条颜色ResourceColor#3d8af2
bgColor进度条背景颜色ResourceColor#fff
strokeWidth进度条宽度number4
duration动画时长number300
strokeLineCap进度端点样式LineCapStyleRound
clockwise是否顺时针booleantrue
startPosition进度条起始位置, 可选值 left right top bottomstringtop