import SwiftUI
struct ReplaceView: View {
@State var isshow = false
var body: some View {
VStack{
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
.onTapGesture {
self.isshow.toggle()
}
}.frame(width: 800, height: 600, alignment: .center)
.sheet(isPresented: $isshow,
content: {TestView(isshow:self.$isshow)})
}
}
struct TestView:View{
@Binding var isshow:Bool
var body:some View{
VStack{
Text("ddd").onTapGesture {
self.isshow = false
}
}.frame(width: 400, height: 300, alignment: .center)
}
}
struct ReplaceView_Previews: PreviewProvider {
static var previews: some View {
ReplaceView()
}
}
这个在mac做了测试
单击文字,d出对话框
单击ddd,隐藏对话框。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)