It seems as though TabView is only a little bit customizable, with some important attributes not being available at all. Can anyone help me out?
Here's some code:
var body: some View {
TabView(selection: $selectedView) {
ScoresGroupView(dataController: dataController, size: .small, goBack: handler)
.tag(ScoresGroupView.smallTag)
.tabItem {
Text(LocalizedStringKey.smallBoard)
.foregroundColor(.yellow)
}
ScoresGroupView(dataController: dataController, size: .medium, goBack: handler)
.tag(ScoresGroupView.mediumTag)
.tabItem {
Text(LocalizedStringKey.mediumBoard)
.foregroundColor(.yellow)
}
ScoresGroupView(dataController: dataController, size: .large, goBack: handler)
.tag(ScoresGroupView.largeTag)
.tabItem {
Text(LocalizedStringKey.largeBoard)
.foregroundColor(.yellow)
}
}
.ignoresSafeArea()
}
The point of this is to show a tabbed high scores screen for small, medium, and large board sizes. The rest of the app is full-screen with a black background and yellow text, so the modifier .ignoresSafeArea()
at the bottom is how I'm trying to avoid having a white stripe of status bar across the top of an otherwise black screen. That doesn't work, though.
Similarly, in each of the tab items there's just a Text
view with the label for the board size, and each has the modifier, .foregroundColor(.yellow)
, with the intent that the text will look like the rest of the text in the application. This, also, doesn't work.
Following a tip in this thread on the Apple Developer forum, I added this line to the init
method on this struct:
UITabBar.appearance().barTintColor = UIColor(Color.black)
This does, indeed, make the tab bar a dark gray, a little bit lighter than the black background of the application. However, the text labels are blue (for the selected tab) or even lighter gray (for the unselected tabs).
I tried wrapping the TabView
in a ZStack
whose first child is Color.black
and then modifying the ZStack
with .ignoresSafeArea
but that didn't change anything. There's still a bright white status bar above a black screen with yellow high score entries and then a gray tab bar across the bottom with tiny, low-contrast blue or gray text labels.