Skip to content

I found another way! #5

@woozoobro

Description

@woozoobro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions