
我试图更改TabBar中所选标签的颜色,但是没有效果. 我可以通过编写更改TabBar backgroundColor

struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.purple
}
var body: some View {
}
}

我们迅速设置了tintColortabbar选中字体颜色,它确实更改了所选标签的颜色. 但是tabbar选中字体颜色,对于swiftUI,我需要做什么?

这是我的代码,

TabView(selection: $selection) {
AView()
.tabItem {
VStack {
Image(systemName: "bubble.left.and.bubble.right")
Text("A Tab")
}
}.tag(0)
BView()
.tabItem {
VStack {
Image(systemName: "house")
Text("B Tab")
}
}.tag(1)
CView()
.tabItem {
VStack {
Image(systemName: "circle.grid.3x3")
Text("C Tab")
}
}.tag(2)
}
方法是:
使用accentColor:
TabView {
// fill this out with your tabbed content
}
.accentColor(.orange)
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-281536-1.html
@彭于晏
我就为了这个更新了~比上一版9
应该拒绝赔偿才对