【发布时间】:2021-01-27 03:16:42
【问题描述】:
我以为我写得对,但 RoundedRectangle 没有动画......我错过了什么? ????
struct BarView: View {
var progress: Double = 0.0
var progressAnimation: Animation {
Animation
.linear
.speed(0.5)
.delay(0.02)
}
var body: some View {
ZStack {
ZStack(alignment: .leading) {
RoundedRectangle(cornerRadius: 12.0)
.fill(Color(.lightGray))
.opacity(0.1)
.frame(height: 15)
.overlay(GeometryReader { geometry in
RoundedRectangle(cornerRadius: 12.0)
.fill(getColorForBar(progress: progress))
.frame(width: getFillWidth(progress: progress, geometry: geometry), height: 15)
.animation(self.progressAnimation)
}, alignment: .leading)
}
}
}
【问题讨论】:
标签: ios swift animation swiftui