How do you bind a Color to .fill()?

visc

I want to bind a color to fill.

.fill($color) // Instance method 'fill(_:style:)' requires that 'Binding<Color>' conform to 'ShapeStyle'

Do I need to create a custom Binding or something? I know I can do a ternary operation on a bound Bool and choose between two colors.. But I want to bind directly to Color.

Asperi

Either your color is a @State or @Binding you can just use

.fill(color)

binding itself is performed automatically by SwiftUI engine - it detects used corresponding properties in body and refresh body whenever those properties changed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related