extension View {
func phoneOnlyStackNavigationView() -> some View {
if UIDevice.current.userInterfaceIdiom == .phone {
return AnyView(self.navigationViewStyle(StackNavigationViewStyle()))
} else {
return AnyView(self)
}
}
}
struct ContentView: View {
@State private var selection = 0
var body: some View {
NavigationView {
VStack {
Button(action: {
}) {
Text("Tap me")
.padding()
.foregroundColor(.white)
.background(Color.blue)
.cornerRadius(8)
}.shadow(color: Color.blue, radius: 20, y: 5)
.frame(width: 300, height: 100, alignment: .trailing)
Text("SwiftUI")
.navigationBarTitle("Nav Title")
}
Color.red.edgesIgnoringSafeArea([.top,.bottom,.leading,.trailing])
}
.phoneOnlyStackNavigationView()
}
}