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 | 控制控件滾動到頂部 |