UIScrollView
@property(nonatomic) CGSize contentSize;
滚动范围(不设置无法滚动)
@property(nonatomic) CGPoint contentOffset;
可以让里面的内容滚动
代码滚动
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
用动画效果滚动
contentOffset:滚动距离
animated:是否可见动画(动画时长固定)
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated;
滚动到指定范围可见
@property(nonatomic) UIEdgeInsets contentInset;
滚动内边距
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;
数值滚动条
@property(nonatomic) CGFloat minimumZoomScale;
最小缩放比例
@property(nonatomic) CGFloat maximumZoomScale;
最大缩放比例
@property(nonatomic) BOOL scrollsToTop __TVOS_PROHIBITED;
点击状态栏滚动到屏幕顶部
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;
缩放完成