开发者

How can I make controls clickable under an image overlay?

开发者 https://www.devze.com 2023-03-11 02:34 出处:网络
I\'m designing an interface/view that I would like to lay an image ontop of.I am using standard UILabels and UIButtons.These buttons are distorted purposefully by the overlaying image, which encapsula

I'm designing an interface/view that I would like to lay an image ontop of. I am using standard UILabels and UIButtons. These buttons are distorted purposefully by the overlaying image, which encapsulates the entire screen. Everything works fine, but as expected, the image is preventing any of the buttons from being pressed.

I've thought about making a second set of transparent buttons, as a third layer, that relays the messages to the buttons under the image, but it feels like a hack. I've also thought about possibly responding to a region on the overlay image click and finding the control which is within the click bounds. I'm very new to iPhone develop开发者_运维知识库ment, so I'm not sure if these methods are acceptable -- or if there is a simple way around my problem. The buttons must be under the overlaying image.

Essentially, I want the effects of the image overlay, with the touch events ignoring the image and going to the controls underneath it.

Any ideas?


I've just created the following imageview over two controls. You can click through it. Just make sure userInteraction is set to NO.

How can I make controls clickable under an image overlay?

view hierarchy -> image is above buttons

How can I make controls clickable under an image overlay?


Try anImageView.userInteractionEnabled = YES. If you are using UIImageView, the default value of userInteractionEnabled is NO.

0

精彩评论

暂无评论...
验证码 换一张
取 消