如何打造“热点区域” UIControl 更大吗?
或者:如何扩展 UIControl 的敏感区域而不只是使视图更大?
我有一个非常小的按钮图像(一个小箭头),只有 10 x 10 像素。太小了,无法触摸。我希望“热点区域”的大小为 50 x 50 左右。为了学习,我想知道如何手动执行此操作,即使我可以使用一些提供的 UIControls 来实现此目的。
Or: How to expand the sensitive area for a UIControl without just making the view bigger?
I have a pretty small button image (a little arrow), which is just 10 x 10 pixels. Too small for touching. I want the "hot area" to be 50 x 50 around that. For learning, I want to know how to do it manually, even if I could use some of the provided UIControls for this purpose.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您始终可以在顶部放置另一个视图 - 也许将 UIButton 设置为自定义类型,因此它是不可见的 - 并让该按钮在被触摸时触发您想要发生的事情。
但您的真正问题是首先使用 10x10 像素区域进行用户控制。我能想到的最小的用户控件(例如,在日历应用程序中)具有大约 30x30 的 [+] 按钮区域。
想想你的用户,问问自己他们在处理微小控件时会有什么体验。
You could always layer another view over top -- perhaps a UIButton set to custom type so it's invisible -- and have that button trigger what you want to happen when it gets touched.
But your real issue is using 10x10 pixel areas for user control in the first place. The smallest user control I can think of (say, in the Calendar app) has about a 30x30 area for the [+] button.
Think of your users and ask yourself what their experience will be dealing with tiny little controls.