How can I make the controls clickable under the image overlay?

I am developing an interface / view that I would like to place on it. I use standard UILabels and UIButtons. These buttons are deliberately distorted by an overlay image that encapsulates the entire screen. Everything works fine, but, as expected, the image prevents you from pressing any of the buttons.

I was thinking of creating a second set of transparent buttons, like a third layer, which sends messages to the buttons under the image, but it looks like a hack. I also thought about possibly responding to the region with a click overlay and finding a control that is within the limits of the click. I'm very new to iPhone development, so I'm not sure if these methods are acceptable - or if there is an easy way to solve my problem. The buttons should be under the overlay image.

Essentially, I need image overlay effects, with touch events ignoring the image and moving to the controls below it.

Any ideas?

+4
source share
2 answers

I just created the following image with two controls. You can click on it. Just make sure UserInteraction is set to NO.

enter image description here

view hierarchy → image above buttons

enter image description here

+4
source

Try anImageView.userInteractionEnabled = YES. If you use UIImageView, the default value for userInteractionEnabled is NO.

0
source

All Articles