'whatever color you want'
어떠 색이든 유저가 컬러를 선택할 수 있는 컬러피커에 대해 알아보자.
엄청 세부적으로 정말 세상 모든 색을 표현할 수 있는데, 사용법은 간단하다.
// Created by Toughie on 2023/04/30.
//
import SwiftUI
struct ColorPickerPrac: View {
@State var backgroundColor: Color = .white
var body: some View {
ZStack {
backgroundColor.ignoresSafeArea()
ColorPicker(
"Select a color",
selection: $backgroundColor,
supportsOpacity: true)
.padding()
.background(Color.black.opacity(0.7))
.cornerRadius(10)
.foregroundColor(.white)
.font(.headline)
.padding(100)
}
}
}
'SwiftUI > SwiftUI(Basic)' 카테고리의 다른 글
39. [SwiftUI] Stepper() 스테퍼, Strideable (0) | 2023.05.01 |
---|---|
38. [SwiftUI] DatePicker() 데이트피커 (0) | 2023.04.30 |
36. [SwiftUI] Picker() 피커 (0) | 2023.04.30 |
35. [SwiftUI] Toggle() 토글 (0) | 2023.04.30 |
34. [SwiftUI] TextEditor, Safe Area에 대한 탐구 (0) | 2023.04.30 |