๐ ฟ๏ธShape
โฑ๐ง under construction -> Canvas, Shape ๅฟ ้ ๅ ทๅ็้บผ็น่ณช๏ผ
SwiftUI โฉ shapes โฉ Shape (protocol)
Shape is a "push-out" view.
// protocol definition
protocol Shape : Sendable, Animatable, View, _RemoveGlobalActorIsolationIf 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.

SwiftUI โฉ
SwiftOnTap โฉ View โฉ .clipShape(_:style:) โ some View
Shape๏ผshape.fill(content) ็ๅกซๅ ๆจฃๅผ content ๆฏ ShapeStyleใ
inherits from View, Animatable.
Path conforms to Shape.
can have animations.
can be filled.
can be clipped using even-odd fill mode.
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())Shape โฉ .path(in:)
็ฏไพ
Last updated
Was this helpful?