Я только начал изучать приложения Swiftui для iOS. Я хочу использовать его для моего бокового меню. У моего табвижу 6 вкладок, и я заметил, что кнопка «больше» появляется внизу с тремя точками. Мне удалось скрыть эту кнопку, используя. Тем не менее, я все еще получаю кнопку «больше» в левом верхнем углу двух последних вкладок, и я не могу найти способ ее удалить. < /P>
Мой код: < /p>
import SwiftUI
//Standard Color for Background
let standardColor = Color(red: 0.96, green: 0.94, blue: 0.88)
struct ContentView: View {
@State private var showMenu = false //Variable die ausgibt ob das Menu gezeigt wird @State sagt aus das es eine Var ist die aktualisert wird
@State private var selectedTab = 0
var body: some View {
NavigationStack{
/*@START_MENU_TOKEN@*//*@PLACEHOLDER=Container@*/VStack/*@END_MENU_TOKEN@*/ {
ZStack {
TabView(selection: $selectedTab){
Group{
home()
.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
}
Text("Appointments")
.tag(3)
.transaction {transaction in
transaction.animation = .default
}
Text("Purchase")
.tag(4)
.transaction {transaction in
transaction.animation = .default
}
Text("Profile")
.tag(5)
.transaction {transaction in
transaction.animation = .default
}
}
//.toolbarBackground(.hidden, for: .tabBar) Braucht man nicht wenn toolbarVisibility hidden ist
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
sideMenuView(isShowing: $showMenu, selectedTab: $selectedTab)
}
.toolbar(showMenu ? .hidden : .visible, for: .navigationBar)
.navigationBarTitleDisplayMode(.inline)
.animation(.easeInOut , value: showMenu)
.toolbar{
ToolbarItem(placement: .topBarLeading){
Button(action:{showMenu.toggle()},
label:{
Image(systemName: "line.horizontal.3")
.foregroundColor(.black)
})
}
ToolbarItem(placement: .principal) {
let (title, imageName) = selectNavigationName(tab: selectedTab)
HStack {
Text(title)
.font(.headline)
Image(systemName: imageName)
.imageScale(.small)
.bold(true)
}
}
}
}
}
}
func selectNavigationName(tab: Int) -> (String, String) {
switch tab {
case 0:
return ("Home", "house")
case 1:
return ("Us", "heart")
case 2:
return ("ToDo", "list.bullet")
case 3:
return ("Appointments", "calendar")
case 4:
return ("Purchase", "cart")
case 5:
return ("Profile", "person.circle")
default:
return ("Home", "house")
}
}
}
#Preview {
ContentView()
.modelContainer(for: ToDo.self)
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... iew-with-6