The second version of SwiftUI and iOS14 introduced a new extremely helpful Color Picker.
First, you need State property to keep the selected color and it has to be Color instance.
@State private var color = Color.red
Next, create a ColorPicker view and bind this color.
ColorPicker(“Pick background color”, selection: $color)
You can hide the label if you want.
.labelsHidden()
This small circle shows what the current color is selected. It’s so small, let’s use that color as the background and ignore safe area to remove white spaces.
ZStack {
color
.ignoresSafeArea()
ColorPicker(“Pick background color”, selection: $color)
.labelsHidden()
}