#鸿蒙通关秘籍#在Polygon组件中如何设置边框样式?

HarmonyOS
2024-12-04 14:54:10
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
时光笔BI

Polygon组件支持设置边框端点和拐角的绘制样式,分别通过strokeLineCapstrokeLineJoin方法。以下是设置这些属性的示例:

@Entry
@Component
struct PolygonExample {
  build() {
    Column({ space: 10 }) {
      Polygon({ width: 100, height: 100 })
        .points([[0, 0], [50, 100], [100, 0]])
        .stroke(Color.Blue)
        .strokeWidth(5)
        .strokeLineCap(LineCapStyle.Round)
        .strokeLineJoin(LineJoinStyle.Bevel)
    }
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

在此示例中,strokeLineCap将边框端点样式设为圆形,而strokeLineJoin将拐角样式设为斜面。

分享
微博
QQ
微信
回复
2024-12-04 15:41:40
相关问题