如何获取 UIScrollView 中的当前缩放级别?
为了尝试创建一种解决方法,使图像在 UIScrollView 中居中并使其表现得像 Apple 的照片应用程序一样,我需要获取当前的缩放级别并使用该数字来计算图像在每个缩放级别应插入的量。
(注意:我知道一些程序员通过将图像集中在与滚动视图大小相同的 UIView 中来将图像集中在滚动视图中。这不会给出好的结果,我正在尝试找出苹果如何使其工作在照片应用程序中。)
那么,有人知道如何获取 UIScrollView 中内容的当前缩放级别吗?
In an attempt to create a workaround for centering an image in a UIScrollView and make it behave as Apple's Photos app does, I need to get the current zoom level and use the number to calculate the amount the image should be inset at each zoom level.
(Note: I am aware that some programmers are centering an image in a scrollview by centering the image in a UIView that is the same size as the scrollview. This does not give good results and I am trying to find out how apple made it work in the photos app.)
So, anyone know how to get the current zoom level of the content in a UIScrollView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,我得到了你的问题的答案。我认为你应该在你的scrollViewController类中使用这个方法。
Yep I got your problem's answer. I think you should use this method in your scrollViewController Class.
在 OS 3.x 中,有一个名为“zoomScale”的属性可以满足您的需求。在 2.x 中,我相信你可以直接查看 contentView 的转换来获得它(但这当然不是“官方的”。)
In OS 3.x, there's a property called "zoomScale" that will give you what you want. In 2.x, I believe you can look directly at the contentView's transform to obtain this (but that is, of course, not 'official'.)