ColorPicker 는 현재 선택한 색상을 표시하는 색상 저장소를 제공하고, 사용자가 새로운 색상을 선택할 수 있도록 도와준다.
기본 코드
struct ContentView: View {
@State private var bgColor = Color.white
var body: some View {
VStack {
ColorPicker("배경화면 선택", selection: $bgColor)
.padding()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(bgColor)
.edgesIgnoringSafeArea(.all)
}
}
실행 화면
개발자 Document
https://developer.apple.com/documentation/swiftui/colorpicker
Apple Developer Documentation
developer.apple.com
'Language > Swift' 카테고리의 다른 글
SwiftUI 에서 Path 사용하기 (0) | 2022.12.15 |
---|---|
SwiftUI 에서 반복문 사용하기 (ForEach) (0) | 2022.12.14 |
SwiftUI를 이용한 날짜 피커 이용하기 (DatePicker) (0) | 2022.12.11 |
SwiftUI를 이용한 Shape 지정하기 (0) | 2022.12.09 |
SwiftUI를 이용한 뷰를 겹겹이 쌓기 (ZStack) (0) | 2022.12.08 |
댓글