博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS 中 contentsize contentoffset contentInset的区别
阅读量:7024 次
发布时间:2019-06-28

本文共 989 字,大约阅读时间需要 3 分钟。

hot3.png

contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。
 
contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
 
contentInset
 
是scrollview的contentview的顶点相对于scrollview的位置,例如你的
 
contentInset
 
 = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示
 
另外UITableView是UIScrollView的子类,它们在上述属性又有所不同,tabelview的contentsize是由它的下列方法共同实现的
 
- (NSInteger)numberOfSections;
 
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
 
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
 
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
 
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
 
它会自动计算所有的高度和来做为它的contentsize的height.
 
例如你在delegate方法
 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 
    return 100;
 
}
 

转载于:https://my.oschina.net/u/2444750/blog/498399

你可能感兴趣的文章
XPosed框架_简单的应用
查看>>
蓝桥杯——神奇算式(相乘与结果同数)
查看>>
python3 速查参考- python基础 7 -> 函数编程之 装饰器、生成器
查看>>
mysql操作
查看>>
行内元素图片默认顶对齐,文字是底对齐
查看>>
深入浅出讲解:php的socket通信
查看>>
防止网页被嵌套
查看>>
线性回归,多项式回归(P2)
查看>>
Session管理
查看>>
Excel两列查找重复值
查看>>
Vue Element-ui table只展开一行
查看>>
爬虫——请求库之selenium模块
查看>>
JavaScript 面向对象的编程(三) 类的继承
查看>>
redis 指定端口 启动
查看>>
21. Merge Two Sorted Lists
查看>>
SQL Server中date和datetime的区别
查看>>
HDu Battle
查看>>
python学习笔记Day4
查看>>
网站域名重定向
查看>>
Python全栈开发-有趣的小程序
查看>>