Coder Social home page Coder Social logo

hide-tabbar-in-swiftui's People

Contributors

treattrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hide-tabbar-in-swiftui's Issues

I found another way!

TabBarCustom

There's a .toolbar(.hidden, for: .tabBar) modifier.

Put this modifier in the destination View.

And then

In the ContentView

struct ContentView: View {
    @State private var selection: Int = 0
    
    var body: some View {

        TabView(selection: $selection) {
            HomeView()
            .tabItem {
                Image(systemName: "house")
            }
            .toolbarBackground(.visible, for: .tabBar)
            .tag(0)
            
            NavigationStack {
                ForumView()
            }
            .tabItem {
                Image(systemName: "text.bubble")
            }
            .toolbarBackground(.visible, for: .tabBar)
            .tag(1)
            
            NavigationStack {
                ProjectsView()
            }
            .tabItem {
                Image(systemName: "folder.fill")
            }
            .toolbarBackground(.visible, for: .tabBar)
            .tag(2)

            LoginRootView()
            .tabItem {
                Image(systemName: "person.crop.circle")
            }
            .toolbarBackground(.visible, for: .tabBar)
            .tag(3)
        }
        .tint(Color.orange)
        .animation(.spring(response: 0.3, dampingFraction: 0.6), value: selection)
        .toolbar(.visible, for: .tabBar)        
    }

.animation(.spring(response: 0.3, dampingFraction: 0.6), value: selection)

Put this animation in the TabView's selection property

Hiding TabBar is broken in iOS 15.2

Your exact solution worked over a year ago, but unfortunately, it appears to be broken with the latest updates from Apple. I fear this is not a viable solution for iOS 15. Can you verify this? Or, have I overlooked something?

Get Error Information When Run the Demo

I just cloned this repo and open it using Xcode 12.4, ran it on a simulator iPhone 12 with iOS 14.4. However, once build secceeded, I got the error info below:

2021-03-21 11:39:59.111302+0800 HideTabBarInNavigationView[18305:556332] [LayoutConstraints] Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60000016c3c0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7fad35f28ba0]-(6)-[_UIModernBarButton:0x7fad35f26940'Tab1']   (active)>",
    "<NSLayoutConstraint:0x60000016c410 'CB_Trailing_Trailing' _UIModernBarButton:0x7fad35f26940'Tab1'.trailing <= BackButton.trailing   (active, names: BackButton:0x7fad35f251f0 )>",
    "<NSLayoutConstraint:0x600000168730 'UINav_static_button_horiz_position' _UIModernBarButton:0x7fad35f28ba0.leading == UILayoutGuide:0x600001b01960'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x600000168780 'UINavItemContentGuide-leading' H:[BackButton]-(0)-[UILayoutGuide:0x600001b50700'UINavigationBarItemContentLayoutGuide']   (active, names: BackButton:0x7fad35f251f0 )>",
    "<NSLayoutConstraint:0x600000141d10 'UINavItemContentGuide-trailing' UILayoutGuide:0x600001b50700'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x7fad35d13530.trailing   (active)>",
    "<NSLayoutConstraint:0x600000168f00 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7fad35d13530.width == 0   (active)>",
    "<NSLayoutConstraint:0x600000165ef0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x600001b01960'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x7fad35d13530 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60000016c3c0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7fad35f28ba0]-(6)-[_UIModernBarButton:0x7fad35f26940'Tab1']   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

When I tap Here is Tab1 Tap me to NavigatedView things goes well. However, when return to ContentView (by clickinig <Tab1 on left upper corner), I got another error info printed in the console:

Trying to pop to a missing destination at /Library/Caches/com.apple.xbs/Sources/Monoceros_Sim/Monoceros-120/Shared/NavigationBridge_PhoneTV.swift:341
  • Can I just ignore these errors because the required function (hiding TabBar) goes well?

English is not my native language; please excuse typing errors. Any advice will be helpful!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.