UITapGestureRecognizer – you can recognize the touch not only on the buttons, but on any object on the view, even touching the area itself.
For example: when you click on any place of view, the background color should change from white to red. Create a UIView – the size in the full screen of the device, the background color is white. And we create UITapGestureRecognizer to which we assign the function myviewTapped (see the picture).

Swift Programming

Apple Xcode