SwiftUI can't tap in Spacer of HStack

前端 未结 7 537
北海茫月
北海茫月 2020-12-28 12:08

I\'ve got a List view and each row of the list contains an HStack with some text view(\'s) and an image, like so:

HStack{
    Text(group.name)
    Spacer()
          


        
7条回答
  •  旧时难觅i
    2020-12-28 12:32

    As I've recently learned there is also:

    HStack {
      ...
    }
    .contentShape(Rectangle())
    .onTapGesture { ... }
    

    Works well for me.

提交回复
热议问题