如何在UIScrollView中获取当前缩放级别? [英] How can I get the current zoom level in a UIScrollView?

查看:141
本文介绍了如何在UIScrollView中获取当前缩放级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建一个解决方法,使图像在UIScrollView中居中并使其表现为Apple的照片应用程序,我需要获取当前缩放级别并使用该数字来计算图像应插入每个图像的数量缩放级别。

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.

(注意:我知道有些程序员将图像置于滚动视图中心,方法是将图像置于与滚动视图大小相同的UIView中。这不是给出了很好的结果,我试图找出苹果如何在照片应用中发挥作用。)

(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.)

所以,任何人都知道如何获得内容的当前缩放级别在UIScrollView中?

So, anyone know how to get the current zoom level of the content in a UIScrollView?

推荐答案

在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'.)

这篇关于如何在UIScrollView中获取当前缩放级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆