Created
June 8, 2022 23:50
-
-
Save anupamchugh/9f999153edd903f7e7d256a2e77621cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SwitchLayouts : View{ | |
@State private var switchStack: Bool = false | |
var body: some View{ | |
let layout = switchStack ? AnyLayout(HStack()) : AnyLayout(VStack()) | |
VStack{ | |
Button { | |
self.switchStack.toggle() | |
} label: { | |
Text("Switch") | |
} | |
layout { | |
RoundedRectangle(cornerRadius: 20) | |
.fill(.orange) | |
RoundedRectangle(cornerRadius: 20) | |
.fill(.blue) | |
} | |
.frame(width: 200, height: 200) | |
} | |
.padding() | |
.animation(.default, value: self.switchStack) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment