UIScrollView
@property(nonatomic) CGSize contentSize;
滾動范圍(不設(shè)置無法滾動)
@property(nonatomic) CGPoint contentOffset;
可以讓里面的內(nèi)容滾動
代碼滾動
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
用動畫效果滾動
contentOffset:滾動距離
animated:是否可見動畫(動畫時長固定)
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;
滾動到指定范圍可見
@property(nonatomic) UIEdgeInsets contentInset;
滾動內(nèi)邊距
UIEdgeInsetsMake(20, 20, 20, 20);
@property(nullable,nonatomic,weak) id<UIScrollViewDelegate> delegate;
代理
@property(nonatomic) BOOL bounces;
彈簧
@property(nonatomic,getter=isPagingEnabled) BOOL pagingEnabled;
分頁
@property(nonatomic) BOOL showsHorizontalScrollIndicator;
水平滾動條
@property(nonatomic) BOOL showsVerticalScrollIndicator;
數(shù)值滾動條
@property(nonatomic) CGFloat minimumZoomScale;
最小縮放比例
@property(nonatomic) CGFloat maximumZoomScale;
最大縮放比例
@property(nonatomic) BOOL scrollsToTop __TVOS_PROHIBITED;
點(diǎn)擊狀態(tài)欄滾動到屏幕頂部
UIScrollViewDelegate
- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
縮放的時候縮放哪個視圖
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
開始滾動
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
正在滾動
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
滾動完成
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view;
開始縮放
- (void)scrollViewDidZoom:(UIScrollView *)scrollView;
正在縮放
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale;
縮放完成