Color Picker introduced from iOS 14 Until now, we have implemented PickerView and Slider by ourselves to provide color selection functions, etc. It may have been implemented, but it has become very easy to do.
The selected color is used as the background color.
struct ContentView: View {
@State private var color = Color.white
var body: some View {
ZStack{
color
.edgesIgnoringSafeArea(.all)
ColorPicker(selection: $color, label: {
Text("SelectColor")
})
.padding()
.onChange(of: color, perform: { value in
print(color)
})
}
}
}
Now you can add ColorPicker. Changes during color selection can be handled with onChange. Is this area the same as a normal Picker?
The app has been released! Please install it if you like. Toranpo
I started Twitter! Please follow me if you like. @yajima_tohshu
Recommended Posts