contentOffset在UIScrollView中做了什么? [英] What does contentOffset do in a UIScrollView?

查看:128
本文介绍了contentOffset在UIScrollView中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UIScrollView contentOffset 属性的用途是什么?

What is the use of the contentOffset property in UIScrollView?

推荐答案

根据 文档 contentOffset 属性表示:



内容视图的原点从滚动视图的原点
偏移的点。

The point at which the origin of the content view is offset from the origin of the scroll view.

简单来说,它是视图在每个方向(垂直和水平)移动的距离。您可以通过访问 CGPoint <的 x y 属性来解包垂直和水平距离

In plain speak, it's how far the view has moved in each direction (vertical and horizontal). You can unpack vertical and horizontal distance by accessing the x and y properties of the CGPoint:

CGFloat xOffset = _myScrollView.contentOffset.x;
CGFloat yOffset = _myScrollView.contentOffset.y;

这篇关于contentOffset在UIScrollView中做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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