【发布时间】:2020-03-05 14:49:30
【问题描述】:
我正在尝试为某些文本设置颜色变化的动画,但我似乎无法让它逐渐变化。我已经尝试过隐式和显式动画,如下面的代码所示,但没有骰子......
struct Example: View {
@State var showing = false
var body: some View {
VStack {
Text("test text").foregroundColor(showing ? .red : .blue)
.animation(.easeIn(duration: 2))
Button(action: toggle) {
Text("Toggle")
}
}
}
func toggle() {
withAnimation(.easeIn(duration: 2)) {self.showing.toggle()}
}
}
谁能指点一下?
【问题讨论】:
标签: swiftui