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.
Asked
Active
Viewed 3,379 times
1 Answers
4
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
- 13,108
- 13
- 75
- 116
-
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 Feb 07 '10 at 04:04
-
3Touches are ignored when the alpha of a view is less than 0.1. – Ian Henry Feb 07 '10 at 04:30
-
1With clearColor even on a UIView, you cannot detect touches. Although at least with iOS 8 it seems it will detect touches with alpha 0.01 instead of 0.1 which is nice! – Jordan H Jul 14 '14 at 04:46
-
2Yup, just tested 0.01 alpha and it works. I find it annoying that a clearColor view cannot receive touches. They definitely should be getting touches, at least a property to enable this would be better. – Maximilian Litteral Sep 03 '14 at 00:55