У меня есть 3 представления внутри Tabview. Для двух других вкладок внешний вид Tabbar работает нормально, но на представлении, на котором есть карта, внешний вид, кажется, возвращается к дефолту. Я попытался вспомнить код появления Tabbar на MapView Method, но все еще не успешно. Как я могу гарантировать, что внешний вид таббара одинаково для всех вкладок? Код, как показано ниже. < /P>
import SwiftUI
struct LandlordTabView: View {
@State private var selection = 0
var body: some View {
TabView(selection: $selection) {
LandlordAddPropertyView()
.tabItem {
Image(systemName: "house.fill")
Text("Add Property")
}
.tag(0)
LandlordMapView()
.tabItem {
Image(systemName: "map.fill")
Text("Map")
}
.tag(1)
LandlordProfileView()
.tabItem {
Image(systemName: "person.fill")
Text("Profile")
}
.tag(2)
}
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
.onAppear {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .appBlue
appearance.stackedLayoutAppearance.normal.iconColor = .appAliceBlue.withAlphaComponent(0.5)
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.appAliceBlue.withAlphaComponent(0.5)]
appearance.stackedLayoutAppearance.selected.iconColor = .appColumbiaBlue
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.appColumbiaBlue]
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
}
}
}
#Preview {
LandlordTabView()
}
< /code>
import SwiftUI
import MapKit
struct LandlordMapView: View {
var body: some View {
VStack {
Text("Properties")
.padding(.bottom, 10)
.frame(maxWidth: .infinity)
.font(.system(size: 30))
.foregroundColor(.appAliceBlue)
.background(Color.appBlue)
.fontWeight(.bold)
Map()
.frame(height: 200)
Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.appColumbiaBlue)
}
}
#Preview {
LandlordMapView()
}
< /code>
MapView
AddPropertyView
Подробнее здесь: https://stackoverflow.com/questions/795 ... h-have-map
Внешний вид Swiftui Tabbar не работает только в тех видах, которые имеют карту ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Внешний вид Swiftui Tabbar не работает только в тех видах, которые имеют карту
Anonymous » » в форуме IOS - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как сделать Ubibutton.configuration выделять внешний вид, отличный вид кнопок систем
Anonymous » » в форуме IOS - 0 Ответы
- 3 Просмотры
-
Последнее сообщение Anonymous
-