I have a few buttons in my app whose alpha is currently set to zero. These buttons are completely non-responsive, but as soon as I increase their alpha, they begin to respond. Is this expected behavior?
4 Answers
As per Apple's documentation for UIView
's hitTest:withEvent:
method:
This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01.
So any UIView
that has alpha lower than 0.01 will be ignored by the touch events processing system, i.e. will not receive touch.

- 10,293
- 5
- 45
- 60
-
14I tried 0.01 exactly and it disabled the touch events. It has to be at least 0.02 – CSawy Aug 13 '14 at 18:15
-
5@CSawy I tried 0.010001 and it enabled the touch events. so it has to be greater than 0.01 – Musa almatri Oct 05 '19 at 20:42
I'm a little late to the game but you could always set the UIButton background color to clearcolor. This would keep them active. In my case, I am pulsating a button to give it a glowing effect but to do this, I must set it's background to clear, then add a UIIMageView as a subview and add the effect to the image, NOT the button.
Hope this helps anyone else with this problem.

- 333
- 3
- 16
When the alpha is 0 they are unresponsive, as alpha = 0 is like hidden = YES and you can't click a hidden button.

- 4,304
- 4
- 34
- 44
-
5This is an old answer, but don't you mean to say "When the alpha is 0 they are **un**responsive..." – Duncan C May 15 '17 at 14:07
-
I just tried to edit this answer replacing "responsive" with "unresponsive" but got "edits must be more than six characters". This Stack Overflow requirement is especially bad considering that this answer was the one chosen by google in their snippet up the top of their search results. And no-one can correct it. – tomblah Feb 04 '20 at 05:29
Yes, the least alpha amount should be 3.0 / 255.0
for touch event to not be ignored.

- 10,847
- 10
- 42
- 75