ios - 如何用黑色填充灰色空间?SwiftUI
问题描述
.onTapGesture {
self.showModal = true
}.sheet(isPresented: self.$showModal, onDismiss: {
// addEntry()
// requestReviewIfNeeded()
self.showModal = false
}, content: {
BiographyDetail(biography: self.biography)
Button(action: {
showModal = false
}) {
Text("CLOSE")
.foregroundColor(.gray)
.background(Color.black).ignoresSafeArea()
}
})
感谢您的帮助!
解决方案
这是一种可能的方法 - 使用颜色作为背景并将特定内容放置在此颜色的叠加层中。
使用 Xcode 13 / iOS 15 测试
.sheet(isPresented: $showModal) {
Color.black
.ignoresSafeArea() // << consumes all space
.overlay( // << content is overlaid
VStack(spacing: 0) {
BiographyDetail(biography: self.biography)
Button(action: {
showModal = false
}) {
Text("CLOSE")
.foregroundColor(.gray)
.background(Color.black).ignoresSafeArea()
}
})
}
推荐阅读
- regression - 在 jupyter 中使用 OLS 方法进行多元线性回归时出现此错误 - TypeError: cannot perform reduce with flexible type
- spring-boot - Springboot:将从swagger UI捕获的JWT令牌自动传递给下游(服务到服务)API调用
- java - 在 java 镜像 jdk8 镜像之上安装 python 3.7
- javascript - 如何通过 Jasmine 在 JS 中测试(单元测试)箭头函数?
- python - 迁移 python 2 到 3:types.FileType
- python - 检查给定路径中是否存在文件夹,如果不存在则在此处创建文件夹
- amazon-web-services - 当状态机执行被中止时,cloudformation 如何处理基于 AWS Step 函数的自定义资源?
- android - 从 kotlin 应用程序在 s3 上上传音频文件
- html - html中的title属性无法解析特殊字符
- python - 选择行值不为空的列名 pandas 数据框