如何更改标签栏背景颜色and将 sf 符号设置为自定义颜色?我已经尝试过 .tabitem 下的背景(颜色:颜色),其上方,括号内
我尝试使用符号来执行 .palette (因为我做了一个我想使用的自定义颜色),但我不知道如果它在标签中我无法修改它?我也尝试过 .foregroundcolor 。少了什么东西?
struct Home: View {
var body: some View {
TabView {
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Logout")
.foregroundColor(.white)
}
}
.tabItem {
Label("Logout", systemImage: "arrow.left")
}
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Home")
.foregroundColor(.white)
}
}
.tabItem {
Image(systemName: "house")
Text("Home")
}
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Add")
.foregroundColor(.white)
}
}
.tabItem {
Label("Add", systemImage: "plus")
}
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Ship")
.foregroundColor(.white)
}
}
.tabItem {
Label("Ship", systemImage: "shippingbox")
}
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Order")
.foregroundColor(.white)
}
}
.tabItem{
Label("Order", systemImage: "bag")
}
NavigationView {
ZStack{
Color.black
.edgesIgnoringSafeArea(.top)
Text("Reports")
.foregroundColor(.white)
}
}
.tabItem {
Label("Reports", systemImage: "doc")
}
}
}
}
可以通过选定选项卡项目的强调色和其他内容的外观修改来实现
使用 Xcode 14 / iOS 16 进行测试
struct Home: View {
init() {
UITabBar.appearance().backgroundColor = .blue
UITabBar.appearance().unselectedItemTintColor = .white
}
var body: some View {
TabView {
}
.accentColor(.yellow)
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)