我需要在视图上画一条线,无论如何都要让这条线是直的,但长度是动态的
好的,我需要为我正在开发的 iPad 应用程序实现一个简单的测量工具。我没有任何绘画经验,所以我真的很挣扎。当用户按下视图时(在测量模式下),线的原点开始。然后,我需要能够在用户拖动手指的任何地方画一条线,当他们拖动手指时,并且始终保持笔直。
我有基于两个 UITapGestureRecognizers 计算两点之间距离的逻辑,但我想我需要实现 TouchBegan/Ended 方法。
如何在用户拖动时画一条线,并使其始终保持笔直?
我只需要一个正确方向的点。
谢谢!!
Ok I need to implement a simple measuring tool for an iPad app I am working on. I don't have any experience with drawing, so I am really struggling. When the user presses down on the view (in measuring mode) the line's origin starts. I need to then be able to draw a line to wherever the user drags their finger, as they are dragging their finger, and have it be straight the entire time too.
I have the logic that calculates the distance between two points working based on two UITapGestureRecognizers, but I am thinking I will need to implement the touchesBegan/Ended methods instead.
How can I draw a line as the user drags, and make it stay straight the entire time?
I just need a point in the right direction.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看这个这样的好教程。
跳到绘制线条的部分:
然后是对该方法的调用:
Check out a good tutorial like this.
Skip to the section on drawing lines:
and then here is the call to that method: