我该如何在SwiftUI中关闭按钮高亮显示,当它被点击或按下时。
这是我的代码:
ScrollView {
ForEach(searchManager.resultUsers) { user in
Button(action: {
self.showProfile = true
self.user = user
}) {
SearchUserRow(user: user)
.foregroundColor(.primary)
}
}
}.sheet(isPresented: $showProfile) {
ProfileView(profileUser: self.user)
.environmentObject(ProfileManager(userID: self.user.userID, fetchingMode: .user(mode: .tweets)))
}
如果我移除按钮并将
onTapGesture
添加到 SearchUserRow
上,那么只有内容部分是可选择的,而不是整个行。
.foregroundColor(.primary)
。 - Mojtaba Hosseini