The problem that I have is that I want to display a map of the world. I want the user to be able to click on a specific country. I know that I can make my UIImages(the pictures of the countries) the images of UIButtons but this does not work in my case because even if a UIButton is a custom button it is in a rectangular shape. Since countries on maps are not rectangular, the buttons will overlap and then when you are trying to click on one country you end up clicking on another. What is the best way to recognize a click from the user and then figure out which image they were intending to click on?
EDIT: I forgot to mention this but if I was able to get the coordinates of a user’s tap, is there a way I could check if the pixel tapped on was a blank/transparent pixel in my UIImage?
You can add a
UITapGestureRecognizerto yourUIImageView, which will return both when a user taps the image and the coordinates of the tap itself. From the coordinates you can establish which country the user is clicking.