我目前正在使用 SwiftUI 开发应用程序。
我正在寻找某种方法在工作表视图上制作具有不透明度的背景颜色。
有没有办法做到这一点?
我已经尝试使用下面的代码来做到这一点,我可以使用 opacity 属性更改颜色,但是我在工作表视图下看不到文本(工作表)...
import SwiftUI
struct ContentView: View {
@State var isSheet = false
var body: some View {
Button(action: {self.isSheet.toggle()}) {
Text("Sheet")
}.sheet(isPresented: $isSheet){
Color.yellow.opacity(0.5)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
Xcode:版本 11.7
斯威夫特:斯威夫特 5