开发者

iPhone -- Why doesn't touchesBegan fire on UIViews when alpha is set to zero?

Is there some optimization going on that removes the view or something? I still want it to recieve touch even开发者_Go百科ts even though I've made it transparent. Seems these events don't fire if alpha == 0 though.


You're right, touches don't get detected on transparent views:

"By default, a view receives touch events, but you can set its userInteractionEnabled property to NO to turn off delivery of events. A view also does not receive events if it’s hidden or if it’s transparent."

How about setting the view to 1% alpha, or even a few points? Maybe your UI should show a ghost overlay anyways.

The other thing you could do is make a UIView subclass, frame it to the same size, and overlay it. A UIView has a background color of [UIColor clearColor] by default, but you can still detect touches on it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜