【发布时间】:2020-06-07 12:56:17
【问题描述】:
我有一个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>) {
}
}
如何使我的所有视图中的状态栏变为橙色?
【问题讨论】:
-
这能回答你的问题吗? SwiftUI: Status bar color
-
不,这不会只是改变文本而不是背景颜色@pawello2222
-
您应该使用
Color.orange.edgesIgnoringSafeArea(.all),这样它应该会扩大以填充未覆盖的区域。