SwiftUI can't tap in Spacer of HStack

前端 未结 7 546
北海茫月
北海茫月 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条回答
  •  情歌与酒
    2020-12-28 12:38

    works like magic on every view:

    extension View {
            func onTapGestureForced(count: Int = 1, perform action: @escaping () -> Void) -> some View {
                self
                    .contentShape(Rectangle())
                    .onTapGesture(count:count, perform:action)
            }
        }
    

提交回复
热议问题