iOS开发之UIScrollView中frame、contentSize、contentOffset、contentInset
来源:互联网 发布:宋仲基和杨洋长相知乎 编辑:程序博客网 时间:2024/05/16 01:23
UIScrollView有三个属性,分别为contentSize、contentOffset、contentInset,再加上UI View的属性frame,共四个属性,由于这四个属性存在一定的关联,不仔细很容易弄混,所以抽时间好好了解了一下。
UIScrollView的四个属性在官方文档中是这样的:
/* use bounds/center and not frame if non-identity transform. if bounds dimension is odd, center may be have fractional part */@property(nonatomic) CGRect frame;// default CGSizeZero@property(nonatomic) CGSize contentSize;// default CGPointZero@property(nonatomic) CGPoint contentOffset;// default UIEdgeInsetsZero. add additional scroll area around content@property(nonatomic) UIEdgeInsets contentInset;
frame
frame是scrollView视图的位置和大小,为一个矩形框,数据类型为CGRect。
frame数据类型为CGRect,有四个参数值,分别为
- frame.origin.x: 表示视图位置原点的x值
- frame.origin.y: 表示视图位置原点的y值
- frame.size.width: 表示视图的宽度
- frame.size.height: 表示视图的高度
contentSize
contentSize是scrollView需要显示的内容大小,是一个矩形框,因为contentSize是可以滚动的,因此只有大小而没有位置,数据类型为CGSize。
contentSize数据类型为CGSize,只有两个参数,分别为
- contentSize.width: 表示显示内容的宽度
- contentSize.height: 表示显示内容的高度
contentOffset
contentOffset是scrollView的contentSize的原点相对于frame原点的偏移量,是两个点之间的相对值,数据类型为CGPoint。
contentOffset数据类型为CGPoint,只有两个参数,分别为
- contentOffset.x: 表示contentSize在x方向上的偏移量(有正负值)
- contentOffset.y: 表示contentSize在y方向上的偏移量(有正负值)
contentInset
contentInset是scrollView的contentSize相对于自身四个边框的显示范围变化值,数据类型为UIEdgeInsets。
contentInset数据类型为UIEdgeInsets,有四个参数,分别为
- contentInset.top: 表示contentSize上边距显示范围变化值(有正负值)
- contentInset.bottom: 表示contentSize下边距显示范围变化值(有正负值)
- contentInset.left: 表示contentSize左边距显示范围变化值(有正负值)
- contentInset.right: 表示contentSize右边距显示范围变化值(有正负值)
frame、contentSize、contentOffset、contentInset四者之间的关系
frame、contentSize、contentOffset、contentInset四者之间存在着一定的关系,见下图。
0 0
- iOS开发之UIScrollView中frame、contentSize、contentOffset、contentInset
- iOS中UIScrollView的frame、contentSize、contentOffset和contentInset属性
- UIScrollView的frame,contentSize,contentOffset,contentInset属性
- IOS开发—UIScrollView的contentSize、contentInset、contentOffset的理解
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性(转)
- UIScrollView中contentSize、contentInset、contentOffset介绍
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- URAL K-based Numbers(1-3)
- python对象:访问私有属性和私有方法
- 文章标题SSL 1763 观光旅游
- 欢迎使用CSDN-markdown编辑器
- HDU 1171 Big Event In HDU 背包拆分
- iOS开发之UIScrollView中frame、contentSize、contentOffset、contentInset
- Redis集群之主从复制,读写分离(上)(五)
- Ubuntu 安装maven
- Swift 可选类型
- vs中修改程序默认堆栈大小
- objc-class-ref in 错误
- GoF(设计模式)
- Android WebView使用
- skynet给集群中的一个节点配置多个通道