UIButton 的 alpha 设置为 0.0 时会被禁用吗? [英] Does UIButton become disabled when its alpha is set to 0.0?
问题描述
我的应用中有几个按钮的 alpha 当前设置为零.这些按钮完全没有响应,但是一旦我增加它们的 alpha,它们就会开始响应.这是预期的行为吗?
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?
推荐答案
根据 Apple 的文档,用于 UIView
的 hitTest:withEvent:
方法:
As per Apple's documentation for UIView
's hitTest:withEvent:
method:
此方法忽略隐藏的、已禁用的视图对象用户交互,或者 alpha 水平小于 0.01.
This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01.
因此,任何 alpha 低于 0.01 的 UIView
都将被触摸事件处理系统忽略,即不接收触摸.
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.
这篇关于UIButton 的 alpha 设置为 0.0 时会被禁用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!