我试图更改 TabBar 中选定选项卡的颜色,但没有任何效果。我可以更改 TabBarbackgroundColor
通过写作
struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.purple
}
var body: some View {
}
}
很快,我们设置tintColor
它确实改变了所选选项卡的颜色。但是我需要为 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)
}
有什么帮助吗?
提前致谢!!
Use accentColor
: https://developer.apple.com/documentation/swiftui/tabview/3368073-accentcolor https://developer.apple.com/documentation/swiftui/tabview/3368073-accentcolor
TabView {
// fill this out with your tabbed content
}
.accentColor(.orange)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)