-1.3 C
New York
Monday, February 3, 2025

ios – The best way to take away the “Extra” button from the higher left in a SwiftUI TabView with 6 tabs


I simply began studying programming SwiftUI apps for iOS.

I am at the moment growing an app utilizing SwiftUI and I’ve encountered a problem with the TabView element. I need to use it for my Facet Menu. My TabView has 6 tabs, and I observed {that a} “Extra” button seems on the backside with three dots. I managed to cover this button by utilizing .toolbarVisibility(.hidden, for: .tabBar). Nevertheless, I am nonetheless getting a “Extra” button within the higher left nook of the final two tabs, and I am unable to discover a strategy to take away it.

My code:

import SwiftUI

//Commonplace Coloration for Background
let standardColor = Coloration(purple: 0.96, inexperienced: 0.94, blue: 0.88)

struct ContentView: View {
    @State personal var showMenu = false    //Variable die ausgibt ob das Menu gezeigt wird @State sagt aus das es eine Var ist die aktualisert wird
    @State personal var selectedTab = 0
    
    var physique: some View {
        NavigationStack{
            /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Container@*/VStack/*@END_MENU_TOKEN@*/ {
                ZStack {
                    TabView(choice: $selectedTab){
                        Group{
                            residence()
                                .tag(0)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                            
                            ourdate()
                                .tag(1)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                            
                            
                            ToDoView()
                                .tag(2)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                            
                            Textual content("Appointments")
                                .tag(3)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                            
                            Textual content("Buy")
                                .tag(4)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                            
                            Textual content("Profile")
                                .tag(5)
                                .transaction {transaction in
                                    transaction.animation = .default
                                }
                        }
                        //.toolbarBackground(.hidden, for: .tabBar) Braucht man nicht wenn toolbarVisibility hidden ist
                        .tabViewStyle(PageTabViewStyle(indexDisplayMode: .by no means))
                        
                    }
                    
                    
                    sideMenuView(isShowing: $showMenu, selectedTab: $selectedTab)
                }
                .toolbar(showMenu ? .hidden : .seen, for: .navigationBar)
                .navigationBarTitleDisplayMode(.inline)
                .animation(.easeInOut , worth: showMenu)
                .toolbar{
                    ToolbarItem(placement: .topBarLeading){
                        Button(motion:{showMenu.toggle()},
                               label:{
                            Picture(systemName: "line.horizontal.3")
                                .foregroundColor(.black)
                        })
                    }
                    ToolbarItem(placement: .principal) {
                        let (title, imageName) = selectNavigationName(tab: selectedTab)
                        HStack {
                            Textual content(title)
                                .font(.headline)
                            Picture(systemName: imageName)
                                .imageScale(.small)
                                .daring(true)
                            
                        }
                    }
                }
            }
        }
    }
    
    func selectNavigationName(tab: Int) -> (String, String) {
        change tab {
        case 0:
            return ("House", "home")
        case 1:
            return ("Us", "coronary heart")
        case 2:
            return ("ToDo", "record.bullet")
        case 3:
            return ("Appointments", "calendar")
        case 4:
            return ("Buy", "cart")
        case 5:
            return ("Profile", "particular person.circle")
        default:
            return ("House", "home")
        }
    }
    
}

#Preview {
    ContentView()
        .modelContainer(for: ToDo.self)
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles