Scrollview
来源:互联网 发布:java高级家架构师培训 编辑:程序博客网 时间:2024/05/16 12:30
UIScrollView继承UIView,它有两个子类,分别是UITableView和UITextView。UIScrollView有三个容易让人混淆的属性变量:
假如一个scrollview的frame为(0,0,320,480),而它的contentSize为(320,960).也就是说,这个scrollview整个内容的大小为(320,960),要通过上下滑动scrollview来查看(320,480)后的内容。
它有点类似css中的padding。
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
- ScrollView
- ScrollView
- scrollView
- ScrollView
- ScrollView
- ScrollView
- ScrollView
- ScrollView
- ScrollView
- ScrollView
- scrollView
- ScrollView
- ScrollView
- scrollview
- ScrollView
- ScrollView
- scrollView
- ScrollView
- Android学习之WebView文档翻译
- 刷题_day3_vv
- 2440 上内核3.4.2移植
- [JAVA · 初级]:19.容器类
- virtio sr-iov
- Scrollview
- SASS的简单运用,css更快
- zcmu1138
- int和boolean,String类型的数组存值输出问题
- 毕设第一天开发
- oracle用cmd命令连接数据库
- list遍历的四种方法
- HDU 4568 (SPFA 状压DP)
- 软件项目外包的优缺点