tags:

views:

138

answers:

1

Is there some optimization going on that removes the view or something? I still want it to recieve touch events even though I've made it transparent. Seems these events don't fire if alpha == 0 though.

+1  A: 

You're right, touches don't get detected on transparent views:

"By default, a view receives touch events, but you can set its userInteractionEnabled property to NO to turn off delivery of events. A view also does not receive events if it’s hidden or if it’s transparent."

How about setting the view to 1% alpha, or even a few points? Maybe your UI should show a ghost overlay anyways.

The other thing you could do is make a UIView subclass, frame it to the same size, and overlay it. A UIView has a background color of [UIColor clearColor] by default, but you can still detect touches on it.

Andrew Johnson
Thanks for reading the docs for me :)
morgancodes
Setting the alpha to 0.001 has the same effect as setting it to zero. Seems to me your clearcolor view is a safer/better approach.
morgancodes
Touches are ignored when the alpha of a view is less than 0.1.
Ian Henry