UITapGestureRecognizer sender is the gesture, not the ui object UITapGestureRecognizer sender is the gesture, not the ui object xcode xcode

UITapGestureRecognizer sender is the gesture, not the ui object


You can get a reference to the view the gesture is added to via its view property. In this case you are adding it to the button so the view property would return you you the button.

let button = sender.view as? UIButton