-
-
Save robb/ea3cb47136ee8e01faf4527f47833b16 to your computer and use it in GitHub Desktop.
This file contains 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
import SwiftUI | |
struct ContentView: View { | |
@State var show: Bool = false | |
var body: some View { | |
ZStack { | |
Button { | |
show.toggle() | |
} label: { | |
Text("Show") | |
} | |
GeometryReader { proxy in | |
ZStack(alignment: .bottom) { | |
Color.clear | |
if show { | |
Text("Hello once upon a time there was a duck named Ducky who went on to drink lots of juice boxes and live happily ever after") | |
.padding() | |
.frame(maxWidth: .infinity, alignment: .center) | |
.padding(.bottom, proxy.safeAreaInsets.bottom) | |
.background( | |
Color.green | |
.cornerRadius(20.0) | |
) | |
.transition(.move(edge: .bottom)) | |
.zIndex(1) | |
} | |
} | |
.edgesIgnoringSafeArea(.bottom) | |
} | |
.border(.red) | |
.animation(.linear(duration: 1.0), value: show) | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment