我想绑定(bind)一种颜色来填充。
.fill($color) // Instance method 'fill(_:style:)' requires that 'Binding<Color>' conform to 'ShapeStyle'
我需要创建自定义Binding
或其他内容吗?我知道我可以对绑定(bind)的 Bool
进行三元运算并在两种颜色之间进行选择。但我想直接绑定(bind)到 Color
。
最佳答案
您的颜色
是您可以使用的@State
或@Binding
.fill(color)
绑定(bind)本身由 SwiftUI 引擎自动执行 - 它会检测 body
中使用的相应属性,并在这些属性发生更改时刷新 body。
关于swiftui - 如何将 Color 绑定(bind)到 .fill()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64084035/