我正在尝试更改TabBar中选定选项卡的颜色,但是没有任何效果。我可以backgroundColor
通过编写 来更改TabBar
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) }
有什么帮助吗?提前致谢!!
使用accentColor
:https : //developer.apple.com/documentation/swiftui/tabview/3368073-accentcolor
TabView { // fill this out with your tabbed content } .accentColor(.orange)