Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button doesn't trigger action when the alpha is 0

I have a button that working fine when his alpha is 1, but when I set the alpha to 0, it doesn't do the functions. (I want the button to be invisible, but still responsive). how do I fix that?

thanks!

like image 960
Daisy the cat Avatar asked Sep 20 '25 17:09

Daisy the cat


2 Answers

Setting the alpha to 0, will disable the UIView and no touch events will be received, so you need to set it to 0.02 at least.

Source is this answer on SO : Does UIButton become disabled when its alpha is set to 0.0?

like image 118
Mohammad Assad Arshad Avatar answered Sep 22 '25 13:09

Mohammad Assad Arshad


According to Apple Docs

This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01. This method does not take the view’s content into account when determining a hit. Thus, a view can still be returned even if the specified point is in a transparent portion of that view’s content.

Any UIView that has alpha lower than 0.01 will be ignored by the touch events processing system, i.e. will not receive touch. Set it 0.02 at least

like image 30
Jawad Ali Avatar answered Sep 22 '25 12:09

Jawad Ali