ZStack背景色不显示

时间:2020-06-08 08:20:17

标签: ios swift swiftui mapkit

这是我的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

enter image description here

知道为什么吗?

0 个答案:

没有答案