iPhone,能够隐藏视图并触摸它吗?
显然,
self.hidden = YES;
self.userInteractionEnabled = YES;
隐藏视图但无法识别触摸事件。
有没有办法隐藏视图并触摸它?
apparently,
self.hidden = YES;
self.userInteractionEnabled = YES;
hides the view but doesn't recognize touch events.
Is there a way of hiding a view and touching it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有办法做到这一点。 解决方案是创建另一个空的 UIView。这个新 UIView 的唯一目的是捕获点击。
这是实现这一目标的唯一方法。
(根据您的需要,您也许还可以制作一个大的透明按钮。)
alpha 是一个著名的问题。如果你对 UIView 进行 alpha 处理,它就会变得不可点击。如果您可以看到它,则只能单击它。希望有帮助。
There is NO way to do this. The solution is to make another UIView, which is empty. The only purpose of this new UIView is to catch the click.
That is the only way to do it.
(You could also perhaps make a large transparent button, depending on your needs.)
The alpha thing is a famous gotchya. If you alpha away a UIView, it becomes unclickable. You will only be able to click it, if you can see it. Hope it helps.
将背景颜色设置为清除对我有用。您可能还需要设置文本颜色。
set the backgroundColor to clear works for me. You may also need to set the text color.