UIView alpha 0 但仍接收触摸事件? [英] UIView alpha 0 but still receive touch events?
本文介绍了UIView alpha 0 但仍接收触摸事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图隐藏一个 uiview,但仍然让它接收触摸事件.我将 alpha 设置为 0,如下所示:
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
我也试过将其设置为 true 但它没有做任何事情
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?
推荐答案
将 UIView
的 backgroundColor
设置为 UIColor.clear
.
Set your UIView
's backgroundColor
to UIColor.clear
.
mainView.backgroundColor = .clear
这篇关于UIView alpha 0 但仍接收触摸事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文