๐ ฟ๏ธShape
โฑ๐ง under construction -> Canvas, Shape ๅฟ ้ ๅ ทๅ็้บผ็น่ณช๏ผ
SwiftUI โฉ shapes โฉ Shape (protocol)
Shape
is a "push-out" view.
// protocol definition
protocol Shape : Sendable, Animatable, View, _RemoveGlobalActorIsolation
If you need the efficiency or flexibility of immediate mode drawing โ for example, to create particle effects โ use a Canvas
view instead.
Polygon - an animatable polygon shape.
Examples

import SwiftUI
import PlaygroundSupport
// ContentView
struct ContentView: View {
// body
var body: some View {
VStack{
hstack1
hstack2
}.padding()
}
var hstack1: some View {
HStack{
Group{
Triangle()
.stroke()
Triangle()
.fill(Color.red)
Triangle()
.stroke(Color.red, style: StrokeStyle(lineWidth: 10, lineCap: .round, lineJoin: .round))
Arc(start: 110, end: 0, clockwise: true)
.stroke(lineWidth: 10)
.stroke(lineWidth: 5)
.stroke()
}
.frame(width: 100, height: 100)
.border(Color.orange)
}
}
var hstack2: some View {
HStack{
Group{
Arc(start: 90, end: 0, clockwise: true)
.stroke(Color.blue, lineWidth: 20)
Arc(start: 0, end: 270, clockwise: true)
.stroke(Color.pink, lineWidth: 8)
}
.frame(width: 208, height: 100)
.border(Color.yellow)
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
็ฏไพ
Last updated
Was this helpful?