这是我的ZStack
:
struct HomeView: View {
@State var selectedTab = 1
var body: some View {
ZStack {
TabView(selection: $selectedTab) {
Settings()
.tabItem {
Image(systemName: "gear").font(.system(size: 25))
Text("Settings")
}.tag(0)
ZStack {
Color.black
MapView()
VStack {
Spacer()
Button(action: {}){
Text("Offline")
.font(.system(size: 25))
.fontWeight(.bold)
.foregroundColor(Color.white)
}.padding().background(Color.black).opacity(0.7).cornerRadius(40.0)
}.padding(40)
}.edgesIgnoringSafeArea(.top)
.tabItem {
Image(systemName: "location.circle.fill").font(.system(size: 25))
Text("Home")
}.tag(1)
ProfileView()
.tabItem {
Image(systemName: "person").font(.system(size: 25))
Text("Profile")
}.tag(2)
}.accentColor(Color.white)
.font(.headline)
}.edgesIgnoringSafeArea(.top)
}
}
在上方您可以看到我将Color.black
应用于了ZStack
的{{1}}-但是MapView()
的背景不是黑色的:
MKMapView
知道为什么吗?