How can I change the colour of tab bar in Xcode 14 and how to put it into my code.
code:
import SwiftUI
struct ContentView: View {
@State private var selection = 1
var body: some View {
TabView(selection: $Selection) {
Home()
.tabItem { Label("Home", systemImage: "house.fill") }.tag(1)
About()
.tabItem { Label("About", systemImage: "person.crop.circle") }.tag(2)
Products()
.tabItem { Label("Products", systemImage: "bag.fill") }.tag(3)
Gallery()
.tabItem { Label("Gallery", systemImage: "photo.on.rectangle") }.tag(4)
Contact()
.tabItem { Label("Contact", systemImage: "phone.bubble.left.fill") }.tag(5)
}
.accentColor(Color("Green"))
}
}
for some reason apple keeps changing how to do this
CodePudding user response:
struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.blue
}
}
CodePudding user response:
UITabBar.appearance().backgroundColor = UIColor.blue