Hi everyone. New to SwiftUI and still trying to wrap my head around everything.
I'm looking at creating a Custom Color Picker for my app and I am being shown an error in the Preview that i just dont know how to fix.
It mentions a missing argument for parameter "selectedColor" in call
I know why it is bringing up the error but I've tried many ways to fix the issue and they seem to bring up other issues.
Does anyone know what is missing in the code below?
import SwiftUI
struct CustomColorPicker: View {
@Binding var selectedColor: Color
let colors: [Color] = [.red,
.orange,
.yellow,
.green,
.cyan,
.blue,
.purple,
.indigo,
.pink,
.teal,
.brown]
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 20) {
ForEach(colors, id: \.self) { color in
Button {
selectedColor = color
} label: {
Circle()
.fill(color)
.frame(width: 50, height: 50)
.overlay(
Circle()
.stroke(Color.white, lineWidth: self.selectedColor == color ? 3 : 0)
)
}
}
}
}
}
}
struct CustomColorPicker_Previews: PreviewProvider {
static var previews: some View {
CustomColorPicker()
}
}