iOS UIScrollView之contentOffset
来源:互联网 发布:易建联伦敦奥运会数据 编辑:程序博客网 时间:2024/06/14 12:11
版权声明:本文为博主原创文章,未经博主允许不得转载。
UIScrollView继承UIView,它有两个子类,分别是UITableView和UITextView。UIScrollView有三个容易让人混淆的属性变量:
1、contentSize:scrollview可显示的区域
属性类型:
struct CGSize {
CGFloat width;
CGFloat height;
};
typedef struct CGSize CGSize;
- @property(nonatomic) CGSize contentSize
- Description The size of the content view.
- Availability iOS (2.0 and later)
- Declared In UIScrollView.h
- Reference UIScrollView Class Reference
2、contentOffset:scrollview当前显示区域顶点相对于frame顶点的偏移量
属性类型:
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
- @property(nonatomic) CGPoint contentOffset
- Description The point at which the origin of the content view is offset from the origin of the scroll view.
- Availability iOS (2.0 and later)
- Declared In UIScrollView.h
- Reference UIScrollView Class Reference
经过测试发现:CGFloat offsetY = scrollView.contentOffset.y;
当scrollview向下拉时,offsetY为负数;当上拉时,offsetY不断增大,当越过原点后会变成正数。
比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了4803、contentInset:scrollview的contentview的顶点相对于scrollview的位置
属性类型:
typedef struct UIEdgeInsets {
CGFloat top, left, bottom, right;
} UIEdgeInsets;
- @property(nonatomic) UIEdgeInsets contentInset
- Description The distance that the content view is inset from the enclosing scroll view.
- Availability iOS (2.0 and later)
- Declared In UIScrollView.h
- Reference UIScrollView Class Reference
它有点类似css中的padding。
0 0
- iOS UIScrollView之contentOffset
- iOS UIScrollView之contentOffset
- iOS UIScrollView之contentOffset
- iOS UIScrollView的contentOffset
- iOS开发之UIScrollView中frame、contentSize、contentOffset、contentInset
- iOS: UIScrollView的属性contentOffset
- IOS中UIScrollView的contentSize、contentOffset属性
- iOS基础控件:UIScrollView 之三大属性 contentOffset 、contentSize 、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、contentInset、contentOffset的理解
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- IOS中UIScrollView的contentSize、contentOffset和contentInset属性
- 只启动系统相机(排除第三方相机)
- 在python中使用epoll
- 洛谷 P1538 迎春舞会之数字舞蹈
- java LinkedBlockingDeque队列源码解读
- 淘宝tomcat远程调试
- iOS UIScrollView之contentOffset
- Android:防止过快点击造成多次事件
- java多线程
- 计算机操作系统 LRU算法 缺页中断
- ajax 请求进入到error
- MySQL带参数的存储过程小例子
- iosApp上线流程
- iOS 开发仿网易云音乐歌词海报
- [POJ3641] 伪素数