Tyler Tyler - 7 months ago 46
Swift Question

UIView alpha 0 but still receive touch events?

I am trying to hide a uiview but still have it receive touch events. I am setting the alpha to 0 like so:

mainView.alpha = 0.0

also I've tried setting this to true but it doesn't do anything

mainView.userInteractionEnabled = true

Trouble is it no longer receives touch events when I do this. How can I enable it to receive touch events but be effectively hidden?


Set your UIView's backgroundColor to clearColor.

mainView.backgroundColor = UIColor.clearColor()