关闭 SwiftUI 中的按钮突出显示

Turn off button highlighting in SwiftUI

当点击或按下按钮时,如何关闭 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,则无法选择整行,只能选择内容部分。

试试这个,它对我有用,但由于我没有 SearchUserRow() 代码,我无法自己完全尝试:

SearchUserRow(user: user).foregroundColor(.primary)
    .contentShape(Rectangle())
    .onTapGesture { ... }