【发布时间】:2021-03-02 07:48:39
【问题描述】:
我有 2 张图像具有 onTapGesture 。当我点击一张图片时,我可以看到只有点击过的图片被点击,但是我的问题是 fullScreenCover 。如果我单击任何图像,它始终默认为 PersonMain 图像视图,然后转到 InboxView() 。我尝试将 fullScreenCover 放在 onTapGesture 中,但这不起作用。任何建议都会很棒,因为我是 SwiftUI 的新手。我还将 isOpen 状态设置为 false 并在 Tap 时将其设置为 true 但是第一个 Image View InBoxView() 始终是弹出的。
struct MainView: View {
@State var isOpen = true
var body: some View {
VStack(spacing: 7.0) {
HStack(spacing: 7.0) {
Image("PersonMain")
.padding(.leading, 30.0)
.buttonStyle(BorderlessButtonStyle())
.frame(width:20.0, height: 25.0)
.onTapGesture {
print("Profile")
}.fullScreenCover(isPresented: $isOpen,content: {
InboxView()
})
Image("RankingMain")
.padding(.leading, 70.0)
.buttonStyle(BorderlessButtonStyle())
.frame(width: 20.0, height: 25.0)
.onTapGesture {
print("Ranking")
}.fullScreenCover(isPresented: $isOpen,content: {
SearchView()
})
}
}
}
}
【问题讨论】: