In the following snippet, it's obvious that matched geometry effect is overlaying both views and crossfading between them. Is there a way to evenly animate the corner radius change?
struct ContentView: View {
@State var toggled = false
@Namespace var namespace
var body: some View {
VStack(spacing: 16) {
Toggle("Toggle", isOn: $toggled.animation(.linear(duration: 5)))
if toggled {
RoundedRectangle(cornerRadius: 24, style: .continuous)
.fill(.red)
.matchedGeometryEffect(id: "box", in: namespace)
.frame(width: 200, height: 100)
Spacer()
} else {
Spacer()
RoundedRectangle(cornerRadius: 12, style: .continuous)
.fill(.blue)
.matchedGeometryEffect(id: "box", in: namespace)
.frame(width: 100, height: 200)
}
}
.padding(24)
}
}