可缩放图形
我正在尝试在屏幕上绘制可缩放图形。我目前在 ScrollView 中有一个 UIView,我想知道处理/实现我在屏幕上绘制的图形的缩放的最佳方法是什么。
I am trying to draw zoomable graphics onto the screen. I currently have a UIView inside of a ScrollView and I'm wondering what the best way is to go about handling/implementing zooming of the graphics I've drawn on the screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想要使用我在答案中描述的内容这里。
在捏缩放事件期间,变换将应用于您的 UIView,这将缩放内容,但会导致模糊。缩放事件完成后,使用 -scrollViewDidEndZooming:withView:atScale: 委托方法来确定新的比例因子,并适当地调整大小并重新渲染 UIView。如果您在 UIView 的
-drawRect:
方法中使用 Core Graphics 进行绘图,那么这应该很容易管理。You'll probably want to use something along the lines of what I describe in my answer here.
During the pinch-zooming event, a transform will be applied to your UIView, which will zoom the content but will lead to blurring. Once the zooming event is finished, use the
-scrollViewDidEndZooming:withView:atScale:
delegate method to determine the new scale factor and resize and re-render your UIView appropriately. If you're doing your drawing using Core Graphics within the-drawRect:
method of your UIView, this should be pretty easy to manage.