ios - ZStack 背景颜色不显示
问题描述
这是我的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
封闭MapView()
- 但 MKMapView
没有黑色背景:
struct MapView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
mapView.delegate = context.coordinator
return mapView
}
func updateUIView(_ uiView: MKMapView, context: UIViewRepresentableContext<MapView>) {
}
final class Coordinator: NSObject, MKMapViewDelegate {
var control: MapView
init(_ control: MapView) {
self.control = control
}
}
func makeCoordinator() -> Coordinator {
return Coordinator(self)
}
}
知道为什么吗?
解决方案
推荐阅读
- python - 使用 Doc2Vec 训练文档时句子中句号的意义
- python - 如何在 Mako 的一行中重复表达式指定次数
- c# - 将两个单独的数据字段存储到一个数组中 c# Array Json from Class
- android - 如何使用 PEM 证书更新我的反应原生应用程序
- javascript - 我无法将文件上传到我使用 node js multer 指定的目录
- python - 使用 Python 对每月组中的每日数据进行排序
- java - 运行时动态类重定义
- javascript - 在 Create React App 中 React Bundle Size 增加
- typescript - OpenLayers 6.3 和 TypeScript
- mysql - sql查询给出重复的结果