你好,我已经在快速用户界面中创建了一个自定义选项卡栏,其中包含6个选项卡,每个选项卡都嵌入在一个虚化视图中.当我 Select 第五个或第六个选项卡时,我看到顶部有一个"更多"按钮.这几乎就像导航链接的后退按钮.我怎么才能go 掉这个呢?我试着使用导航栏按钮隐藏(真的),但不起作用.我还try 在我的tabView上添加.bar(.idden,意为:.tabbar),但同样不起作用.如果能帮我解开那个按钮,我将不胜感激.谢谢.
import SwiftUI
import Combine
import MapKit
struct MainTabView: View {
@State private var selectedTab = 0
@EnvironmentObject var pop: PopToRoot
@Namespace var animation
init() {
UITabBar.appearance().isHidden = true
}
var body: some View {
TabView(selection: $selectedTab){
NavigationView(){
FeedView()
}.tag(1)
NavigationView(){
JobsView()
}.tag(2)
NavigationView(){
ExploreView()
}.tag(3)
NavigationView(){
QuestionView()
}.tag(4)
NavigationView(){
MessagesHomeView()
}.tag(5)
NavigationStack {
ProfileView()
}.tag(6)
}
.overlay (
HStack {
TabBarButton(change: $selectedTab, title: "Home", index: 1, image: selectedTab == 1 ? "h.circle.fill" : "h.circle", animation: animation)
TabBarButton(change: $selectedTab, title: "Jobs/Shop", index: 2, image: "", animation: animation)
TabBarButton(change: $selectedTab, title: "Explore", index: 3, image: "magnifyingglass", animation: animation)
TabBarButton(change: $selectedTab, title: "Ask", index: 4, image: "questionmark", animation: animation)
TabBarButton(change: $selectedTab, title: "Messages", index: 5, image: selectedTab == 5 ? "message.fill" : "message", animation: animation)
TabBarButton(change: $selectedTab, title: "Profile", index: 6, image: selectedTab == 6 ? "person.crop.circle.fill" : "person.crop.circle", animation: animation)
}
, alignment: .bottom
)
}
}
struct TabBarButton: View {
@Binding var change: Int
var title: String
var index: Int
var image: String
var animation: Namespace.ID
@EnvironmentObject var popRoot: PopToRoot
var body: some View{
Button {
change = index
withAnimation {
popRoot.tab = index
}
} label: {
VStack {
Image(systemName: image).font(.title2)
Text(title).font(.system(size: 10))
}
.foregroundColor(popRoot.tab == index ? .orange : .primary.opacity(0.5))
.frame(maxWidth: .infinity)
.overlay (
ZStack {
if popRoot.tab == index {
TabIndicator()
.fill(.orange.gradient)
.matchedGeometryEffect(id: "TAB", in: animation)
.padding(.top, -9)
.padding(.horizontal, 8)
}
}
)
}
}
}
struct TabIndicator: Shape {
func path(in rect: CGRect) -> Path {
let newRect = CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.width, height: 3)
return Path { path in
path.addRect(newRect)
}
}
}