SwiftUI(3)图形-Shapes
2023-03-07 本文已影响0人
Z小新
Circle() // 圆形
.stroke(style: StrokeStyle(lineWidth: 20,lineCap: .square,dash: [30]))
![](https://img.haomeiwen.com/i5432230/f1bda68a6cd4e25a.png)
Circle() // 圆形
.stroke(style: StrokeStyle(lineWidth: 20,lineCap: .butt,dash: [30]))
.fill(Color.orange)// 填充颜色
![](https://img.haomeiwen.com/i5432230/630914f38d2ebd0d.png)
Circle() // 圆形
.stroke(style: StrokeStyle(lineWidth: 20,lineCap: .round,dash: [30]))
// .fill(Color.orange)// 填充颜色
.foregroundColor(Color.red)// 前景颜色
![](https://img.haomeiwen.com/i5432230/07ed8153aeb05ab2.png)
Ellipse()// 椭圆
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 100)
![](https://img.haomeiwen.com/i5432230/6caa10000a862005.png)
Capsule(style: .circular)// 胶囊
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 100)
![](https://img.haomeiwen.com/i5432230/906bfc51978e5d9d.png)
Rectangle()//矩形
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 100)
![](https://img.haomeiwen.com/i5432230/f9410a0dd5e522c7.png)
RoundedRectangle(cornerRadius: 20)// 圆角矩形
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 100)
![](https://img.haomeiwen.com/i5432230/19e6bcb116ce8e81.png)
RoundedRectangle(cornerRadius: 20)// 圆角矩形
.trim(from: 0.2,to: 1.0)// 修建
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 100)
![](https://img.haomeiwen.com/i5432230/91fccfcd2247e3bd.png)
Circle() // 圆形
.trim(from: 0.0,to: 0.8)// 修建
.stroke(Color.orange,lineWidth: 15)
![](https://img.haomeiwen.com/i5432230/bd839672de2977f7.png)
Circle() // 圆形
.trim(from: 0.5,to: 1.0)// 修建
.fill(Color.orange)// 填充颜色
.frame(width: 200,height: 200)
![](https://img.haomeiwen.com/i5432230/f22d057d54b59a05.png)