darko spa
darko spa

Reputation: 33

uibutons overlaping background image clicking prblem

In this image below i have 6 round rect buttons and each has one of the colored regions as a background

https://i.sstatic.net/uNs0f.png

The problem is that some of the buttons are overlapping which causes the wrong area to be clicked. for example if i click the west colorado area it will select the white area instead of the light blue one. Same problem with west washington and oregon, i click those the light blue area gets selected. No i can slice the images again and add additional buttons where there's overlapping but i wondering if there's a better way to have the button click area be the exact match of the image area.

sorry for not posting the image directly, i dont have enough reputation points

thanks

Upvotes: 3

Views: 133

Answers (1)

wL_
wL_

Reputation: 1007

One possible solution as, Taylor Abernethy Newman mentioned, is to use a UITapGestureRecognizer rather than UIButtons. You can attach a gesture recognizer to your UIImageView, and then use `locationInView:' to determine which region of the map the tap was in and perform the corresponding action.

Upvotes: 2

Related Questions