contentSize是scrollview能够滚动的区域,好比frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),表明你的scrollview能够上下滚动,滚动区域为frame大小的两倍。html
contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,好比上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480iphone
contentInset是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的contentview就是从scrollview的(0 ,100)开始显示post
另外UITableView是UIScrollView的子类,它们在上述属性又有所不一样,tabelview的contentsize是由它的下列方法共同实现的url
- (NSInteger)numberOfSections;spa
- (NSInteger)numberOfRowsInSection:(NSInteger)section;.net
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;htm
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;blog
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;事件
它会自动计算全部的高度和来作为它的contentsize的height.ip
例如你在delegate方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 100;
}
那么你的tabelview的contentsize就是(320, 4400)
属性 | 做用 |
CGPoint contentOffSet | 监控目前滚动的位置 |
CGSize contentSize | 滚动范围的大小 |
UIEdgeInsets contentInset | 视图在scrollView中的位置 |
id<UIScrollerViewDelegate> delegate |
设置协议 |
BOOL directionalLockEnabled | 指定控件是否只能在一个方向上滚动 |
BOOL bounces | 控制控件遇到边框是否反弹 |
BOOL alwaysBounceVertical | 控制垂直方向遇到边框是否反弹 |
BOOL alwaysBounceHorizontal | 控制水平方向遇到边框是否反弹 |
BOOL pagingEnabled | 控制控件是否整页翻动 |
BOOL scrollEnabled | 控制控件是否能滚动 |
BOOL showsHorizontalScrollIndicator | 控制是否显示水平方向的滚动条 |
BOOL showsVerticalScrollIndicator |
控制是否显示垂直方向的滚动条 |
UIEdgeInsets scrollIndicatorInsets | 指定滚动条在scrollerView中的位置 |
UIScrollViewIndicatorStyle indicatorStyle |
设定滚动条的样式 |
float decelerationRate | 改变scrollerView的减速点位置 |
BOOL tracking | 监控当前目标是否正在被跟踪 |
BOOL dragging | 监控当前目标是否正在被拖拽 |
BOOL decelerating | 监控当前目标是否正在减速 |
BOOL delaysContentTouches | 控制视图是否延时调用开始滚动的方法 |
BOOL canCancelContentTouches | 控制控件是否接触取消touch的事件 |
float minimumZoomScale | 缩小的最小比例 |
float maximumZoomScale | 放大的最大比例 |
float zoomScale | 设置变化比例 |
BOOL bouncesZoom | 控制缩放的时候是否会反弹 |
BOOL zooming | 判断控件的大小是否正在改变 |
BOOL zoomBouncing | 判断是否正在进行缩放反弹 |
BOOL scrollsToTop | 控制控件滚动到顶部 |