Rectangle() .foregroundColor(.orange) .frame(width:100, height:100) .gesture( TapGesture(count:1).onEnded {// Action })// Much easier one,// we can use .onTapGesture directly on a viewRectangle() .foregroundColor(.orange) .frame(width:100, height:100) .onTapGesture {// Action }