我正在使用以下代码通过圆圈和复选标记显示成功
struct CheckMarkView: View {
@State var borderInit: Bool = false
@State var spinArrow: Bool = false
@State var dismissArrow: Bool = false
@State var displayCheckmark: Bool = false
var body: some View {
ZStack {
Circle()
.strokeBorder(style: StrokeStyle(lineWidth: borderInit ? 10 : 64))
.frame(width: 128, height: 128)
.foregroundColor(borderInit ? .white : .black)
.animation(.easeOut(duration: 3).speed(1.5))
.onAppear() {
borderInit.toggle()
}
// Arrow Icon
Image(systemName: "arrow.2.circlepath")
.frame(width: 80, height: 80)
.font(.largeTitle)
.foregroundColor(.white)
.rotationEffect(.degrees(spinArrow ? 360 : -360))
.opacity(dismissArrow ? 0 : 1)
.animation(.easeOut(duration: 2))
.onAppear() {
spinArrow.toggle()
withAnimation(Animation.easeInOut(duration: 1).delay(1)) {
self.dismissArrow.toggle()
}
}
// Checkmark
Path { path in
path.move(to: CGPoint(x: 20, y: -40))
path.addLine(to: CGPoint(x: 40, y: -20))
path.addLine(to: CGPoint(x: 80, y: -60))
}
.trim(from: 0, to: displayCheckmark ? 1 : 0)
.stroke(style: StrokeStyle(lineWidth: 10, lineCap: .round, lineJoin: .round))
.foregroundColor(displayCheckmark ? .white : .black)
.offset(x: 150, y: 420)
//.animation(.spring(.bouncy, blendDuration: 2).delay(2))
.animation(Animation.interpolatingSpring(stiffness: 150, damping: 10, initialVelocity: 0).delay(2))
//.animation(Animation.interpolatingSpring(mass: 1, stiffness: 100, damping: 10, initialVelocity: 0).delay(2))
.onAppear() {
displayCheckmark.toggle()
}
}
.background(.black)
}
}
当我try 将框架添加到CheckMarkView时,图像和圆圈会显示在不同的位置.复选标记应显示在圆圈内.此外,复选标记动画结束时也不光滑.如何解决这个问题?如有任何帮助,我们将不胜感激.