UIScrollView ZoomToRect 与 setZoom

发布于 2025-01-03 18:22:50 字数 207 浏览 4 评论 0原文

如果我有一个 UIScrollView,并且我想放大某个位置,那么仅在滚动视图上设置缩放

self.scrollView.zoomScale = MY_NEW_ZOOM;

与计算缩放内的新矩形进行放大和使用

zoomToRect:

Thanks.之间有什么区别吗?

If I have a UIScrollView, and I want to zoom in on a location, is there any difference between just setting the zoom on scrollview like

self.scrollView.zoomScale = MY_NEW_ZOOM;

versus calculating a new rectangle within the zoom to zoom in on, and using

zoomToRect:

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南汐寒笙箫 2025-01-10 18:22:50
  1. zoomScale 仅设置缩放比例,不会更改内容偏移量。

  2. zoomToRect: 将更改缩放比例内容偏移量,以便您给定的矩形可见。

  1. zoomScale just sets the zoom scale and doesn't change the content offset.

  2. zoomToRect: will change the zoom scale and the content offset such that the rect you have given will be visible.

一个人练习一个人 2025-01-10 18:22:50

需要注意的是,您可能需要确保在 ZoomToRect: 中传递的矩形的大小是滚动视图框架的大小。否则,缩放和内容偏移可能不会达到您预期的位置。

Just as a heads up, you may want to ensure that the size of the rect you pass in zoomToRect: is the size of the scrollview's frame. Otherwise the Zoom and Content Offset might not end up where you expect it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文