默認CGPointZero,用來設置scrollView的滾動偏移量。
//設置scrollView的滾動偏移量
scrollView.contentOffset=CGPointMake(0,200);
默認CGSizeZero,用來設置scrollView的滾動范圍。
//設置scrollView的滾動范圍
scrollView.contentSize=CGSizeMake(self.view.bounds.size.width,self.view.bounds.size.height*2);
默認UIEdgeInsetsZero,用來設置scrollView的額外滾動區域。
//設置scrollView的額外頂部滾動區域:(UIEdgeInsetsMake是逆時針設置,上左下右)
scrollView.contentInset=UIEdgeInsetsMake(100,0,0,0);
4. bounces
默認為YES,用來設置scrollView的彈簧效果
//取消scrollView的彈簧效果
scrollView.bounces=NO;
默認為NO,用來設置scrollView是否開啟分頁.
//開啟分頁
scrollView.pagingEnabled=YES;
默認為YES,用來設置scrollView是否允許滾動.
// scrollView禁止滾動
scrollView.scrollEnabled=NO;
默認為YES,用來設置scrollView是否顯示水平滾動條.
//隱藏水平滾動條
scrollView.showsHorizontalScrollIndicator=NO;
默認為YES,用來設置scrollView是否顯示垂直滾動條.
//隱藏垂直滾動條
scrollView.showsVerticalScrollIndicator=NO;
默認1.0,用來設置scrollView最少縮小比例.
//設置scrollView允許子視圖的最大放大比例
scrollView.maximumZoomScale=2;
默認1.0,用來設置scrollView最大放大比例.
//設置scrollView允許子視圖的最小縮放比例
scrollView.minimumZoomScale=0.8;
類要遵守UIScrollViewDelegate協議
scrollView.delegate = self; 聲明scrollView的代理是我,這個方法在UIScrollViewDelegate裡所以我們要遵守UIScrollViewDelegate這個協議
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (void)scrollViewDidZoom:(UIScrollView *)scrollViewNS_AVAILABLE_IOS(3_2);
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView;
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollViewwithVelocity:(CGPoint)velocity targetContentOffset:(inoutCGPoint *)targetContentOffsetNS_AVAILABLE_IOS(5_0);
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollViewwillDecelerate:(BOOL)decelerate;
- (void)scrollViewWillBeginDecelerating:(UIScrollView*)scrollView;
- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView;
- (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView;
// 列如:
- (UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView
{
returnscrollView.subviews[0];
}
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollViewwithView:(UIView *)viewNS_AVAILABLE_IOS(3_2);
- (void)scrollViewDidEndZooming:(UIScrollView*)scrollView withView:(UIView*)view atScale:(float)scale;
scrollViewWillBeginDragging –> scrollViewDidScroll-> scrollViewWillEndDragging -> scrollViewDidEndDragging
scrollViewWillBeginDragging -> scrollViewDidScroll-> scrollViewDidEndDragging ->scrollViewWillBeginDecelerating ->scrollViewDidScroll-> scrollViewDidEndDecelerating
指定控件是否只能在一個方向上滾動
改變scrollerView的減速點位置
監控當前目標是否正在被跟蹤
改變scrollerView的減速點位置
控制視圖是否延時調用開始滾動的方法
控制控件是否接觸取消touch的事件
設定滾動條的樣式
監控當前目標是否正在減速