I am sorry if this has been asked before, I tried searching for a good half hour trying to find out the correct name for what this component might be called if it exists, and I've come up short. This is after spending two hours debugging an unrelated issue with my software, so my nerves aren't quite as fresh as they could be. If I have to do some hackery to get one to display, that's fine. I was just curious if Apple provides an official way to replicate the functionality they provide in their official apps when it comes to that nifty "Slide-Up view" such as the one that appears when writing out a new message in the Mail app. Thanks!
sorry for the short answer yesterday
here is the example implementation:
struct ShowLicenseAgreement: View {
@State private var isShowingSheet = false
var body: some View {
Button(action: {
isShowingSheet.toggle()
}) {
Text("Show License Agreement")
}
.sheet(isPresented: $isShowingSheet,
onDismiss: didDismiss) {
VStack {
Text("License Agreement")
.font(.title)
.padding(50)
Text("""
Terms and conditions go here.
""")
.padding(50)
Button("Dismiss",
action: { isShowingSheet.toggle() })
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
the init requires an isPresented: Binding<Bool>
and a content: View
parameter
(most people use brackets {} for the content)
there is another init
that uses an item set to nil and the sheet shows when the item isn't nil
I hope this can help you if you want more info here is the SwiftUI sheet view developer doc