I’ve 3 views inside tabview. For the opposite two tabs the looks of the tabbar is working fantastic, however on the view which has map on it, the looks appears to return to default. I’ve tried to recall the tabbar look code on mapview onAppear methodology however nonetheless no success. How can I be sure that the tabbar look is identical for all tabs? The code is as under.
import SwiftUI
struct LandlordTabView: View {
@State personal var choice = 0
var physique: some View {
TabView(choice: $choice) {
LandlordAddPropertyView()
.tabItem {
Picture(systemName: "home.fill")
Textual content("Add Property")
}
.tag(0)
LandlordMapView()
.tabItem {
Picture(systemName: "map.fill")
Textual content("Map")
}
.tag(1)
LandlordProfileView()
.tabItem {
Picture(systemName: "particular person.fill")
Textual content("Profile")
}
.tag(2)
}
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
.onAppear {
let look = UITabBarAppearance()
look.configureWithOpaqueBackground()
look.backgroundColor = .appBlue
look.stackedLayoutAppearance.regular.iconColor = .appAliceBlue.withAlphaComponent(0.5)
look.stackedLayoutAppearance.regular.titleTextAttributes = [.foregroundColor: UIColor.appAliceBlue.withAlphaComponent(0.5)]
look.stackedLayoutAppearance.chosen.iconColor = .appColumbiaBlue
look.stackedLayoutAppearance.chosen.titleTextAttributes = [.foregroundColor: UIColor.appColumbiaBlue]
UITabBar.look().standardAppearance = look
UITabBar.look().scrollEdgeAppearance = look
}
}
}
#Preview {
LandlordTabView()
}
import SwiftUI
import MapKit
struct LandlordMapView: View {
var physique: some View {
VStack {
Textual content("Properties")
.padding(.backside, 10)
.body(maxWidth: .infinity)
.font(.system(measurement: 30))
.foregroundColor(.appAliceBlue)
.background(Colour.appBlue)
.fontWeight(.daring)
Map()
.body(top: 200)
Spacer()
}
.body(maxWidth: .infinity, maxHeight: .infinity)
.background(Colour.appColumbiaBlue)
}
}
#Preview {
LandlordMapView()
}