在 UIScrollView 上绘制图像和线条
我正在编写一个应用程序,其中一个 ViewController 正在显示一个显示图像的 UIScrollView。
我想加载一个图像(png 格式的图钉)并在 UIScrollView 图像的某些点上绘制它(并删除它)。
我还想在该图像中绘制贝塞尔路径(并删除它们)。
我已经编写了几个应用程序,但这是我第一次面对图形编程,不知道从哪里开始。
有什么建议吗?
谢谢!
I'm programming an app in which one of the ViewControllers is showing an UIScrollView that shows an image.
I'd like to load an image (pushpin in png format) and draw it (and delete it) in some points of the UIScrollView image.
I'd also would like to draw bezier paths in that image (and deleting them).
I've programmed several apps but this is the first time I face graphic programming and don't know where to start from.
Any suggestions?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为添加到滚动视图的视图设置标签。
这意味着您稍后可以通过以下方式获取对该视图的引用:
如果您想再次删除 pin,您可以使用相同的方法,在 pinView 上设置标记并稍后获取对其的引用,然后对其调用removeFromSuperView。
您还可以选择为滚动内容和 pin 构建属性,但是上面的内容(假设您只需要与滚动视图一起引用它)可以减少很多代码,并且在我看来,实现更容易阅读(给出标签描述性名称如:
所以它是:
希望这就是您想要的:)
You could set the tag for the view you add to the scrollView.
This means you can get a reference to the view later on by:
If you want to remove the pin again, you can use the same approach, set the tag on the pinView and get a reference to it later on and call removeFromSuperView on it.
You can also chose to build properties for both scroll content and pin, but the above (assuming you only need to reference it in conjunction with the scrollView) makes for a lot less code and, in my view, a easier to read implementation (giving the tags descriptive names like:
So it is:
Hope this was what you were after:)