iOS Swift - Animations
Given this SwiftUI code snippet, what will happen when the button toggles
isExpanded?
struct ContentView: View {
@Namespace var ns
@State var isExpanded = false
var body: some View {
VStack {
if isExpanded {
RoundedRectangle(cornerRadius: 25)
.matchedGeometryEffect(id: "shape", in: ns)
.frame(width: 300, height: 300)
} else {
RoundedRectangle(cornerRadius: 25)
.matchedGeometryEffect(id: "shape", in: ns)
.frame(width: 100, height: 100)
}
Button("Toggle") { isExpanded.toggle() }
}
}
}