Andrew Fletcher published: 20 February 2021 1 minute read
SwiftUI’s sheets are used to present new views over existing ones, while still allowing users to drag down to dismiss the new view when they are ready. To use a sheet, you need to give it something to show (such as a custom view), add a Boolean that defines whether the detail view should be showing, then attach it to your main view as a modal sheet.
However, do you want to know how to change views and to have a fullscreen? Only one change is required... instead of .sheet
write .fullScreenCover
.sheet(isPresented: $apiManager.exists) { MainView() .edgesIgnoringSafeArea(.all) .animation(.easeInOut) .transition(.move(edge: .bottom)) }
.fullScreenCover(isPresented: $apiManager.exists, content: { MainView() .edgesIgnoringSafeArea(.all) .animation(.easeInOut) .transition(.move(edge: .bottom)) })
By way of example:
Button(action: {
//... some action
}) {
Text("Sign In".uppercased())
.font(.custom("SFProText-Medium", size: 18.0))
.tracking(5)
.frame(width: (self.screenSize.width * 0.75), height: 30)
}
.buttonStyle(NextButton())
.padding(.top, 50)
.disabled(self.isDisabled)
.fullScreenCover
(isPresented: $apiManager.exists, content: {
MainView()
.edgesIgnoringSafeArea(.all)
.animation(.easeInOut)
.transition(.move(edge: .bottom))
})
Note, that if you want your sheet to be dismissible by dragging downwards on iOS, use the sheet()
modifier instead.