SwiftUI에는 사각형, 원 및 캡슐과 같은 여러 가지 기본 제공 모양이 있으며 필요에 따라 각 모양을 만들고 색상을 지정하고 배치할 수 있다.
기본 코드
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Circle()
.fill(Color.yellow)
.frame(width: 100, height: 100)
Rectangle()
.fill(Color.blue)
.frame(width: 100, height: 100)
RoundedRectangle(cornerRadius: 20)
.fill(Color.green)
.frame(width:200, height: 100)
Capsule()
.fill(Color.black)
.frame(width: 200, height: 100)
}
}
}
실행 화면
개발자 Document
- Circle() : https://developer.apple.com/documentation/swiftui/circle
- Rectangle() : https://developer.apple.com/documentation/swiftui/rectangle
- RoundedRectangle() : https://developer.apple.com/documentation/swiftui/roundedrectangle
- Capsule() : https://developer.apple.com/documentation/swiftui/capsule
'Language > Swift' 카테고리의 다른 글
SwiftUI를 이용한 색상 선택 Picker 이용하기 (ColorPicker) (0) | 2022.12.12 |
---|---|
SwiftUI를 이용한 날짜 피커 이용하기 (DatePicker) (0) | 2022.12.11 |
SwiftUI를 이용한 뷰를 겹겹이 쌓기 (ZStack) (0) | 2022.12.08 |
SwiftUI를 이용한 그리드 그리기 (LazyVGrid) (2) | 2022.12.05 |
SwiftUI에서 GeometryProxy 사용하기 (0) | 2022.12.01 |
댓글