SwiftUI:
I am trying to transfer to secondView from firstView on iPad Pro(11inch) Horizontal screen,the secondView can not be showed in full screen
here is my code:
import SwiftUI
struct ContentView: View {
@State var showsecondView: Bool = false
var body: some View {
Button(action: {
self.showsecondView.toggle()
}) {
Text("firstView")
}.sheet(isPresented: self.$showsecondView){
secondView(showsecondView: self.$showsecondView)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct secondView: View {
@Binding var showsecondView: Bool
var body: some View {
Text("secondView")
}
}
You should better choose the right topic area: SwiftUI
`sheet` does not seem to provide much option to customize the presented view.
One way to present a view in full screen, is to declare the second view inside the first view, overlapping.
Try something like this:
import SwiftUI struct ContentView: View { @State var showsecondView: Bool = false var body: some View { ZStack { Button(action: { self.showsecondView.toggle() }) { Text("firstView") } if self.showsecondView { SecondView(showsecondView: self.$showsecondView) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color.red) .animation(.easeInOut) .transition(.move(edge: .bottom)) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct SecondView: View { @Binding var showsecondView: Bool var body: some View { VStack { Button(action: { self.showsecondView = false }) { Text("dismiss") } Text("secondView") } } }