如何获取子视图在其父视图坐标系中的有效边界
在我的应用程序中,我允许用户通过添加箭头(自定义 ArrowView)来注释照片。可以添加许多箭头,具有各种缩放和缩放功能。旋转。
我正在尝试通过触摸实现箭头选择。目前,我正在迭代&用于
CGRectContainsPoint(arrowView.frame, touchPoint)
根据触摸手势决定选择哪个箭头。
但是,当某些箭头很大且较小时,这效果不佳。旋转到 45 度(因为框架变大)。
问题: 我想使用转换为父坐标而不是框架的箭头边界。缩放时如何得到这个?是否应用了旋转?
或者,有没有更好的方法来解决这个选择问题?
In my app, I allow the user to annotate a photo by adding arrows (custom ArrowView). There can be many arrows added, with various zoom & rotation.
I am trying implement selecting of arrow by touch. Currently, I am iterating & using
CGRectContainsPoint(arrowView.frame, touchPoint)
to decide which arrow to select based on a touch gesture.
But, this does not work well when some of the arrows are big & rotated to 45 degrees (since the frame becomes big).
Question:
I would like to use bounds of the arrow translated to parent co-ordinates instead of frame. How can I get this when scaling & rotation is applied?
Alternatively, is there a better method to solve this selection problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码找到
touchPoint
下的箭头:This code find the arrow under
touchPoint
: