1.概念
允许滚动和缩放其上的子视图的视图,继承于UIView。
下面👇是搬运了苹果参考上的的属性和方法然后翻译了一下
2.属性与函数
1)管理内容大小和偏移量
1、contentOffset
var contentSize: CGSize { get set }
内容视图的原点与滚动视图的原点偏移的点。
2、contentSize
var contentOffset: CGPoint { get set }
内容视图的大小,表示UIScrollView的大小
3、func setContentOffset
func setContentOffset(_ contentOffset: CGPoint, animated: Bool)
设置与内容视图的原点相对应的偏移量,该偏移量与接收者的原点相对应,第一个参数是偏移量,另外一个是是否展示动画
2)管理内容的插入行为
1、adjustedContentInset
var adjustedContentInset: UIEdgeInsets { get }
从内容插图和滚动视图的安全区域派生的插图。
2、contentInset
var contentInset: UIEdgeInsets { get set }
内容视图从安全区域或滚动视图边缘插入的自定义距离。
3、contentInsetAdjustmentBehavior
var contentInsetAdjustmentBehavior: UIScrollView.ContentInsetAdjustmentBehavior { get set }
用来确认系统的偏移的行为
4、UIScrollView.ContentInsetAdjustmentBehavior
enum ContentInsetAdjustmentBehavior : Int
指示如何将安全区域插图添加到调整后的内容插图中的常数。
5、adjustedContentInsetDidChange()
func adjustedContentInsetDidChange()
当滚动视图的调整后的内容插图发生更改时调用。
3)获取布局指南
1、frameLayoutGuide
var frameLayoutGuide: UILayoutGuide { get }
基于滚动视图的未变换框架矩形的布局指南。
2、contentLayoutGuide
var contentLayoutGuide: UILayoutGuide { get }
基于滚动视图的未变换内容矩形的布局指南。
4)配置滚动视图
1、isScrollEnabled
var isScrollEnabled: Bool { get set }
表示是否可以滚动
2、isDirectionalLockEnabled
var isDirectionalLockEnabled: Bool { get set }
确定它是否在特定方向上禁用滚动。
3、isPagingEnabled
var isPagingEnabled: Bool { get set }
表示滚动试图是否启用分页
4、scrollsToTop
var scrollsToTop: Bool { get set }
表示是否启用滚动到顶部的手势
5、bounces
var bounces: Bool { get set }
表示是否在内容边缘弹回
6、alwaysBounceVertical
var alwaysBounceVertical: Bool { get set }
表示垂直滚动到达内容结尾时是否总是发生跳动。
7、alwaysBounceHorizontal
var alwaysBounceHorizontal: Bool { get set }
表示垂直滚动到达内容结尾时是否总是发生跳动。
5)获取滚动状态
1、isTracking
var isTracking: Bool { get }
表示用户是否触摸内容启动滚动状态
2、isDragging
var isDragging: Bool { get }
表示用户是否已经启动滚动内容
3、isDecelerating
var isDecelerating: Bool { get }
表示用户抬起手指后内容是否在滚动视图中移动。
4、decelerationRate
var decelerationRate: UIScrollView.DecelerationRate { get set }
表示用户抬起手指后的减速率
5、UIScrollView.DecelerationRate
struct DecelerationRate
定义了滚动视图的减速率
6)管理滚动指示器和刷新控件
1、indicatorStyle
var indicatorStyle: UIScrollView.IndicatorStyle { get set }
滚动指示器的样式
2、UIScrollView.IndicatorStyle
enum IndicatorStyle : Int
各种各样的指示器样式
3、showsHorizontalScrollIndicator
var showsHorizontalScrollIndicator: Bool { get set }
表示水平滚动指示器是否可见
4、showsVerticalScrollIndicator
var showsVerticalScrollIndicator: Bool { get set }
表示水平滚动指示器是否可见
5、flashScrollIndicators()
func flashScrollIndicators()
暂时显示滚动指示器
6、refreshControl
var refreshControl: UIRefreshControl? { get set }
与滚动试图关联的刷新控件
7)滚动到特定位置
1、scrollRectToVisible(_:animated:)
func scrollRectToVisible(_ rect: CGRect, animated: Bool)
滚动内容的特定区域,以便在接收器中可见。
8)管理触碰
1、touchesShouldBegin(_:with:in:)
func touchesShouldBegin(_ touches: Set<UITouch>,
with event: UIEvent?,
in view: UIView) -> Bool
通过子类重写手指触碰屏幕内容的默认行为
2、touchesShouldCancel(in:)
func touchesShouldCancel(in view: UIView) -> Bool
返回是否取消与内容子视图相关的触摸并开始拖动。
3、canCancelContentTouches
var canCancelContentTouches: Bool { get set }
这个值表示内容视图中的触摸是否始终导致跟踪。
4、delaysContentTouches
var delaysContentTouches: Bool { get set }
表示滚动视图是否延迟对触摸手势的处理。
5、directionalPressGestureRecognizer
var directionalPressGestureRecognizer: UIGestureRecognizer { get }
底层手势识别用于定向按钮按压。
9)缩放和平移
1、panGestureRecognizer
var panGestureRecognizer: UIPanGestureRecognizer { get }
平移手势的底层手势识别器
2、pinchGestureRecognizer
var pinchGestureRecognizer: UIPinchGestureRecognizer? { get }
缩放手势的底层手势识别器
3、zoom(to:animated:)
func zoom(to rect: CGRect,
animated: Bool)
缩放到内容的特定区域,以便在接收器中可见。
4、zoomScale
var zoomScale: CGFloat { get set }
表示应用于滚动视图内容的当前比例因子,是一个浮点数。
5、setZoomScale(_:animated:)
func setZoomScale(_ scale: CGFloat,
animated: Bool)
设置zoomScale的函数
6、maximumZoomScale \ minimumZoomScale
var maximumZoomScale: CGFloat { get set }
var minimumZoomScale: CGFloat { get set }
应用滚动视图的最大比例因子与最小比例因子。
7、isZoomBouncing
var isZooming: Bool { get }
表示缩放超出了为接收器指定的缩放比例限制。
8、isZooming
var isZooming: Bool { get }
表示当前内容视图正在缩放
9、bouncesZoom
var bouncesZoom: Bool { get set }
当缩放超过最大或最小限制时,确定滚动视图是对内容缩放进行动画处理。
10)控制键盘
1、keyboardDismissMode
var keyboardDismissMode: UIScrollView.KeyboardDismissMode { get set }
在滚动开始时关闭键盘的一种行为,就是选择一种关闭键盘的方法
2、UIScrollView.KeyboardDismissMode
enum KeyboardDismissMode : Int
方法有哪些,列在下面
11)管理索引
1、indexDisplayMode
var indexDisplayMode: UIScrollView.IndexDisplayMode { get set }
滑动时索引展现方式
2、UIScrollView.IndexDisplayMode
enum IndexDisplayMode : Int
索引展现方式的枚举
12)实例属性
1、automaticallyAdjustsScrollIndicatorInsets
var automaticallyAdjustsScrollIndicatorInsets: Bool { get set }
2、horizontalScrollIndicatorInsets
var horizontalScrollIndicatorInsets: UIEdgeInsets { get set }
3、verticalScrollIndicatorInsets
var verticalScrollIndicatorInsets: UIEdgeInsets { get set }