【发布时间】:2021-12-30 13:54:07
【问题描述】:
如何在 SwiftUI 中动态更改颜色,如本例所示
@Binding var randomColor: Color
public var body: some View {
ZStack {
Circle()
.stroke(lineWidth: 20)
.opacity(0.5)
.foregroundColor($randomColor)
}
}
这不起作用,因为.foregroundColor 只需要Color。有什么方法可以将@Binding 与颜色一起使用,或者这不是在 SwiftUI 中使用的方法吗?
【问题讨论】:
标签: swiftui