I’m using a custom tabview to show 6 tabs in the tabview. It’s only limited to 5 so if you add 6, it creates a “More” section and the 5th and 6th tabs are shown in a navigation view. When you view 5th,6th tabs, it show a back navigation bar on top with “more”. I got the tabview to show all 6 tabs without “more” option but when I view 5th, 6th tabs it still show a navigation bar on top with “more” back button. X has implemented this with 6th tabs without the extra navigation bar on the 5,6 tabs, so it’s certainly possible.
Ideally I’m trying to hide the “more “navigation bar from the first view and keep the navigation bar of the actual view.
I have tried
View6()
.tag(Tab.home5)
.navigationBarTitle("")
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
Tabview
VStack(spacing: 0){
TabView(selection: $currentTab) {
View1()
.tag(Tab.home1)
View2()
.tag(Tab.home2)
View3()
.tag(Tab.home3)
View4()
.tag(Tab.home4)
View5()
.tag(Tab.home5)
View6()
.tag(Tab.home6)
}
TabBar()
.toolbar(.hidden, for: .tabBar)
}
Custom Tab builder (shows all 6 tabs instead of a more section on the 5th tab)
@ViewBuilder
func TabBar()->some View{
HStack(spacing: 0){
ForEach(Icons){icon in
let tabColor: SwiftUI.Color = currentTab == icon.tabIcon ? (scheme == .dark ? .white : .black) : .gray.opacity(0.6)
ResizableIconView(IconView: icon.View,color: tabColor)
.aspectRatio(contentMode: .fit)
.frame(width: 30, height: 30)
.frame(maxWidth: .infinity)
.contentShape(Rectangle())
}
}
}
.padding(.horizontal)
.padding(.vertical,10)
.background {
(scheme == .dark ? Color.black : Color.white)
.ignoresSafeArea()
}
}
When I view 5th,6th tabs, extra more navigation is shown as below,
more navigation bar
I tried setting navigationBarBackButtonHidden to true but it doesn’t work. I’ve also tried hiding the navigation bar globally but this removes all navigation bars from alll tabs.
extension UINavigationController {
open override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
navigationBar.isHidden = true
}
}
I think the solution is UIKit related