【发布时间】:2021-01-29 14:05:09
【问题描述】:
我在下面有这个环形视图,这个动画从 100% 的填充环开始并“未填充”到修剪量,我想反转动画,使其从 0 开始并填充到修剪量。
var progressAnimation: Animation {
Animation
.linear
.speed(0.5)
.delay(0.2)
}
var body: some View {
VStack {
ZStack {
Circle()
.stroke(Color(.systemFill).opacity(0.5), style: StrokeStyle(lineWidth: lineWidth))
.frame(height: 125)
Circle()
.trim(from: CGFloat(getTrimLevelForRingFromExertionLevel()), to: 1)
.stroke(ColorManager.getColorsForMetric(metricType: .Exertion(value: mostRecentEffortLevelObject?.effortLevel ?? 0)),
style: StrokeStyle(lineWidth: lineWidth, lineCap: .round, lineJoin: .round, miterLimit: .infinity, dash: [20, 0], dashPhase: 0))
.animation(self.progressAnimation, value: getTrimLevelForRingFromExertionLevel())
.rotationEffect(Angle(degrees: 90))
.rotation3DEffect(Angle(degrees: 180), axis: (x: 1, y: 0, z: 0))
.frame(height: 125)
【问题讨论】:
-
这是否回答了您的问题stackoverflow.com/a/64685825/12299030?
-
这是我在上一个问题中遇到的另一个问题,是的,效果很好!但在我的问题中:我们正在构建一个圆圈,然后对其进行修剪,但是我想将修剪设置为从 0 到修剪而不是从 100% 到修剪。
标签: ios swift animation swiftui