scrollView的几个属性contentSize contentOffset contentInset
contentSize是scrollview可以滾動(dòng)的區(qū)域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滾動(dòng),滾動(dòng)區(qū)域?yàn)閒rame大小的兩倍。
contentOffset是scrollview當(dāng)前顯示區(qū)域頂點(diǎn)相對(duì)于frame頂點(diǎn)的偏移量,比如上個(gè)例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480
contentInset是scrollview的contentview的頂點(diǎn)相對(duì)于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是從scrollview的(0 ,100)開始顯示
?
另外UITableView是UIScrollView的子類,它們?cè)谏鲜鰧傩杂钟兴煌?#xff0c;tabelview的contentsize是由它的下列方法共同實(shí)現(xiàn)的
- (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;
它會(huì)自動(dòng)計(jì)算所有的高度和來做為它的contentsize的height.
?
例如你在delegate方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
????return 100;
}
那么你的tabelview的contentsize就是(320, 4400)
?
zhuan:http://hi.baidu.com/cuikun050959/item/71095500d50e9cd2dce5b021轉(zhuǎn)載于:https://www.cnblogs.com/AbelChen1991/p/3662230.html
總結(jié)
以上是生活随笔為你收集整理的scrollView的几个属性contentSize contentOffset contentInset的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Google帮助IE浏览器实现对SVG支
- 下一篇: 程序员/设计师能用上的 75 份速查表