Hello! We can animate Text color via foregroundStyle very nicely in SwiftUI like so:
Text("Some text here")
.foregroundStyle(boolValue ? Color.green : Color.blue)
withAnimation {
boolValue.toggle()
}
However, if the foregroundStyle is a gradient, the color of the Text view changes immediately without animation.
The code below works to animate a gradient foregroundStyle on an SF Symbol, but it does not work when applied to a Text view. Is it possible to animate a Text view foregroundStyle between gradient values?
Image(systemName: "pencil.circle.fill")
.foregroundStyle(boolValue ? .linearGradient(colors: [.red, .orange], startPoint: .top, endPoint: .bottom) : .linearGradient(colors: [.green, .blue], startPoint: .top, endPoint: .bottom))
Thanks for your help!