I have a simple SwiftUI application. I am using slide menu with animation, it works properly, but when I add TabView items, slide menu not work. In image1 when click slide menu it is work like image2, but when I add TabView like image3, it is not working. Any idea?
Screenshot:
ContentView:
import SwiftUI
struct ContentView: View {
@State private var isShowing = false
var body: some View {
NavigationView {
ZStack {
if isShowing {
SideMenuView(isShowing: $isShowing)
}
HomeView()
.cornerRadius(isShowing ? 20 : 10)
.offset(x: isShowing ? 300 : 0, y: isShowing ? 44: 0)
.scaleEffect(isShowing ? 0.8 : 1)
.navigationBarItems(leading: Button(action: {
withAnimation(.spring()) {
isShowing.toggle()
}
} , label: {
Image(systemName: "list.bullet")
}))
TabView {
NavigationView {
Text("Page One")
.navigationBarTitle("Page One")
}
.tabItem {
Image(systemName: "1.circle")
Text("Page 1")
}
NavigationView {
Text("Page Two")
.navigationBarTitle("Page Two")
}
.tabItem {
Image(systemName: "2.circle")
Text("Page 2")
}
NavigationView {
Text("Page Three")
.navigationBarTitle("Page Three")
}
.tabItem {
Image(systemName: "3.circle")
Text("Page 3")
}
}
.edgesIgnoringSafeArea(.top)
}.onAppear {
isShowing=false
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct HomeView: View {
var body: some View {
ZStack {
Color(.white)
}
}
}

