iPhone - “制水”屏幕上的视图不干扰触摸
我有一些观点,我想绘制一些带有或不带有透明度的文本,并且我希望显示的文本不干扰用户触摸。
我的意思是,例如,假设我有一个带有列表视图和一些按钮的视图。我想在整个内容的顶部显示一些不会移动的文本(和一些图形),以及列表,并且不会捕获用户可以在此文本/图形上进行的触摸并让它们通过例如滚动列表视图。
我该怎么做?
I have some views on wich I'd like to draw some text, with or without transparency, and I'd like this displayed text not to interfere with user touches.
I mean for example, let's say I have a view with a list view and some buttons. I'd like to display on top of the whole thing some text (and some graphics) that does not move, with the list, and that does not catch the touches that the user can make on this text/graphics and let them pass through for exemple to scroll the list view.
How may I do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于每个 UI 组件,最简单的方法是:
这将禁用该组件上的手势和触摸,同时保留与下面/下面的所有内容进行交互的可能性。
因此,您可以创建“水印”视图,禁用交互,将其作为子视图添加到当前视图中,这样就可以了。
The simplest way is this, for every UI component:
This will disable gestures and touches on that component, while leaving the possibility of interacting on everything below/beneath.
So, you can create your "watermark" view, disable interactions, add as a subview to your current view and you'll be fine.
您可能可以使用
CATextLayer< /code>
因为图层不会捕获触摸。其他图形也可以是 CALayer。
You can probably use a
CATextLayer
as layers don't catch touches. The other graphics can beCALayer
s too.