如何编程缩放UIScrollView? [英] How do I programatically zoom a UIScrollView?

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

问题描述

我想以基类不支持的方式缩放和放大缩放。

I'd like to zoom and unzoom in ways the base class doesn't support.

例如,在收到双击后。

推荐答案

我回答自己的问题,玩了东西,让它工作。

I'm answering my own question, after playing with things and getting it working.

Apple在其文档中有一个非常简单的例子,介绍如何处理双击。

Apple has a very-simple example of this in their documentation on how to handle double taps.

进行程序化缩放的基本方法是自己做,

The basic approach to doing programmatic zooms is to do it yourself, and then tell the UIScrollView that you did it.


  • 调整内部视图的边框和边界。

  • 将内部视图标记为需要显示。

  • 告诉UIScrollView有关新内容大小。

  • 计算
    内部视图中应显示
    的部分缩放后,并有
    UIScrollView平移到
    位置。

  • Adjust the internal view's frame and bounds.
  • Mark the internal view as needing display.
  • Tell the UIScrollView about the new content size.
  • Calculate the portion of your internal view that should be displayed after the zoom, and have the UIScrollView pan to that location.

关于你的新内容大小的UIScrollView似乎重置了它当前缩放级别的概念。您现在处于新的1.0缩放系数。因此,您几乎可以肯定要重置最小和最大缩放系数。

Also key: once you tell the UIScrollView about your new contents size it seems to reset its concept of the current zoom level. You are now at the new 1.0 zoom factor. So you'll almost certainly want to reset the minimum and maximum zoom factors.

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

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