scrollView中contentSize、contentInset和contentOffset区别
来源:互联网 发布:如何找钢琴老师 知乎 编辑:程序博客网 时间:2024/06/06 02:40
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;
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.
当scrollview向下拉时,offsetY为负数;当上拉时,offsetY不断增大,当越过原点后会变成正数。
1 0
- scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- ios开发scrollView中contentSize、contentInset和contentOffset区别
- scrollView的contentsize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- contentSize、contentInset和contentOffset区别
- Runtime(五)
- Runtime(六)
- [1] 无线通信:基本概念
- P2P实时音视频之NAT穿越
- 关系型数据库工作原理-高速缓存(翻译自Coding-Geek文章)
- scrollView中contentSize、contentInset和contentOffset区别
- BestCoder Round #77 (div.2)解题报告
- Java基本类型
- 软硬件调试九法:第四条规则 分而治之
- android activity 开启 数据传递
- BZOJ_P2763 [JLOI2011]飞行路线(分层图+最短路)
- hdu 1009 FatMouse' Trade
- ubuntu14.04 Unity Eclipse图标显示异常
- Tyvj1098任务安排