iOS/SwiftUI
SwiftUI - Shape
๐ฅญMango
2023. 3. 1. 23:16
์๋ ํ์ธ์ :D ๋ง๊ณ ์ ๋๋ค๐ฅญ
SwiftUI์ Shape์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค.
shape
SwiftUI์๋ Circle, Rectangle, Ellipse, Capsule ๋ฑ์ ์ฌ๋ฌ๊ฐ์ง ๊ธฐ๋ณธ ๋ํ๋ค์ ์ ๊ณตํ๋ค.
์ด๋ค์ ์ด์ฉํด ์ํ๋ ๋ชจ์, ์์ ์ง์ ํด ์ฌ์ฉํ ์ ์๋ค.
Circle
Circle()
.fill(Color.orange) //์์์ฑ์ฐ๊ธฐ
.foregroundColor(.pink) //์์์ฑ์ฐ๊ธฐ
.stroke() //ํ
๋๋ฆฌ
.stroke(Color.red) //ํ
๋๋ฆฌ์์
.stroke(Color.gray, lineWidth: 30) // ํ
๋๋ฆฌ๋๊ป
.stroke(Color.orange, style: StrokeStyle(lineWidth: 20, lineCap: .butt, dash: [10]))
// StrokeStyle์ ํตํด ์ฌ๋ฌ๊ฐ์ง ์ปค์คํ
๊ฐ๋ฅ
.trim(from: 0.2, to: 1.0) // ๋ํ์ ๋ถ ํ์ํ ๋ถ๋ถ์ ์ ๊ฑฐ
.stroke(Color.purple, lineWidth: 50) // ์ด๋ฐ์์ผ๋ก trim๊ณผ ํจ๊ป ์ฌ์ฉ ๊ฐ๋ฅ
Ellipse
Ellipse()
.frame(width: 200, height: 100)
Capsule
Capsule(style: .circular)
.frame(width: 200, height: 100)
- ํ ์คํธ ๋ค๋ ๋ฒํผ ๋ค์ ๋ฃ๊ณ ์ถ์ ๋ ์ ์ฉ
Rectangle
Rectangle()
.frame(width: 200, height: 100)