I have the following case:
I want to flip this shape with a custom animation. I don't know how to describe it properly.
Whenever I tap on the arrow, it should transform into the other one. Without flipping, rotating, etc. just simply transforming.
If that's not precise enough, feel free to comment!
Demo Code
struct ContentView: View {
@State private var change = false
private let arrowWidth: CGFloat = 80
var body: some View {
Path { path in
path.move(to: .zero)
path.addLine(to: CGPoint(x: arrowWidth/2, y: change ? -20 : 20))
path.move(to: CGPoint(x: arrowWidth/2, y: change ? -20 : 20))
path.addLine(to: CGPoint(x: arrowWidth, y: 0))
}
.stroke(style: StrokeStyle(lineWidth: 12, lineCap: .round))
.frame(width: arrowWidth)
.foregroundColor(.green)
.animation(.default)
.onTapGesture { change.toggle() }
.padding(.top, 300)
}
}
As you can see now it has no animation. I have no idea how to do it.
Any help is much appreciated. Thanks!
Note: I can't do this with two rounded rectangles + simply rotating, since I have an opacity animation, which makes the overlapping visible.
