我有一个ZStack
,上面设置了Color.orange
:
struct HomeView: View {
init() {
UITabBar.appearance().barTintColor = UIColor.orange
}
var body: some View {
ZStack {
Color.orange
TabView {
Settings()
.tabItem {
Image(systemName: "gear")
Text("Settings")
}
MapKitView()
.tabItem {
Image(systemName: "location.circle.fill")
Text("Home")
}
ProfileView()
.tabItem {
Image(systemName: "person")
Text("Profile")
}
}
.font(.headline)
}
}
}
,在这个ZStack
中,我有一个TabView
,其子视图都具有橙色的ZStacks
。但是,这些子视图(包括下面显示的Settings()
和MapKitView()
)没有橙色的状态栏。
设置()
struct Settings: View {
var body: some View {
ZStack {
Color.orange
VStack {
NavigationView {
...
}
}
}
}
}
MapKitView()
struct MapKitView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
return mapView
}
func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapKitView>) {
}
}
如何使状态栏在所有视图中显示为橙色?
答案 0 :(得分:1)
s001# docker network create example_net
s001# docker build --network example_net -t example_image example_image
^^^^^^^^^^^^^^^^^^^
答案 1 :(得分:0)
假设UITabBarController
包含UIHostingController
个实例,则可以通过在UIHostingController
上设置视图背景颜色来解决此问题。
viewControllers?.forEach({ (vc) in
// Set `UIHostingViewController` backgrounds to color the statusbar area.
vc.view.backgroundColor = .orange
})