【发布时间】:2021-07-08 09:42:00
【问题描述】:
我有一个播放/暂停按钮,按下时会发生变化。目前它只是淡入淡出,但我希望它执行一个看起来新颜色流过旧颜色的动画。
这是我目前所拥有的:
if(meditationViewModel.timerIsRunning){
HStack{
Image(systemName: "pause")
Text("STOP")
.bold()
}
.padding()
.foregroundColor(.white)
.background(Color.red)
.cornerRadius(25)
.shadow(radius: 20)
}else{
HStack{
Image(systemName: "play")
Text("PLAY")
.bold()
}
.padding()
.foregroundColor(.white)
.background(Color.green)
.cornerRadius(25)
}
meditationViewModel.timerIsRunning 的变化发生在别处。
【问题讨论】:
标签: swift animation button swiftui