DrawerView
@MainActor
open class DrawerView : NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
抽屉拖拽视图
-
事件代理,默认nil
Declaration
Swift
@MainActor open weak var delegate: DrawerViewDelegate?
-
拖拽方向,如向上拖动视图时为Up,向下为Down,向右为Right,向左为Left。默认向上
Declaration
Swift
@MainActor open var direction: UISwipeGestureRecognizer.Direction { get set }
-
抽屉位置,至少两级,相对于view父视图的originY位置,自动从小到大排序
Declaration
Swift
@MainActor open var positions: [CGFloat] { get set }
-
回弹高度,拖拽小于该高度执行回弹,默认为0
Declaration
Swift
@MainActor open var kickbackHeight: CGFloat
-
是否启用拖拽,默认YES。其实就是设置手势的enabled
Declaration
Swift
@MainActor open var enabled: Bool { get set }
-
是否自动检测滚动视图,默认YES。如需手工指定,请禁用之
Declaration
Swift
@MainActor open var autoDetected: Bool
-
指定滚动视图,自动处理与滚动视图pan手势在指定方向的冲突。先尝试设置delegate为自身,尝试失败请手工调用scrollViewDidScroll
Declaration
Swift
@MainActor open weak var scrollView: UIScrollView? { get set }
-
抽屉视图,自动添加pan手势
Declaration
Swift
@MainActor open private(set) weak var view: UIView? { get }
-
抽屉拖拽手势,默认设置delegate为自身
Declaration
Swift
@MainActor open private(set) lazy var gestureRecognizer: UIPanGestureRecognizer { get set }
-
抽屉视图当前位置
Declaration
Swift
@MainActor open private(set) var position: CGFloat { get }
-
抽屉视图打开位置
Declaration
Swift
@MainActor open var openPosition: CGFloat { get }
-
抽屉视图中间位置,建议单数时调用
Declaration
Swift
@MainActor open var middlePosition: CGFloat { get }
-
抽屉视图关闭位置
Declaration
Swift
@MainActor open var closePosition: CGFloat { get }
-
抽屉视图位移回调,参数为相对view父视图的origin位置和是否拖拽完成的标记
Declaration
Swift
@MainActor open var positionChanged: ((_ position: CGFloat, _ finished: Bool) -> Void)?
-
是否使用物理弹簧动画,默认true
Declaration
Swift
@MainActor open var springAnimation: Bool
-
自定义动画句柄,动画必须调用animations和completion句柄
Declaration
Swift
@MainActor open var animationBlock: ((_ animations: () -> Void, _ completion: (Bool) -> Void) -> Void)?
-
滚动视图过滤器,默认只处理可滚动视图的冲突。如需其它条件,可自定义此句柄
Declaration
Swift
@MainActor open var scrollViewFilter: ((UIScrollView) -> Bool)?
-
自定义滚动视图允许滚动的位置,默认nil时仅openPosition可滚动
Declaration
Swift
@MainActor open var scrollViewPositions: ((UIScrollView) -> [CGFloat])?
-
自定义拖动区域句柄,参数为开始拖动位置,默认nil
Declaration
Swift
@MainActor open var draggingAreaBlock: ((CGFloat) -> CGRect)?
-
自定义滚动视图在各个位置的contentInset(从小到大,数量同positions),默认nil时不处理。UITableView时也可使用tableFooterView等实现
Declaration
Swift
@MainActor open var scrollViewInsets: ((UIScrollView) -> [UIEdgeInsets])?
-
创建抽屉拖拽视图,view会强引用之。view为滚动视图时,详见scrollView属性
Declaration
Swift
@MainActor public init(view: UIView)
-
设置抽屉效果视图到指定位置,如果位置发生改变,会触发抽屉callback回调
Declaration
Swift
@MainActor open func setPosition(_ position: CGFloat, animated: Bool = true)
-
获取抽屉视图指定索引位置(从小到大),获取失败返回0
Declaration
Swift
@MainActor open func position(at index: Int) -> CGFloat
-
判断当前抽屉效果视图是否在指定索引位置(从小到大)
Declaration
Swift
@MainActor open func isPosition(at index: Int) -> Bool
-
设置抽屉效果视图到指定索引位置(从小到大),如果位置发生改变,会触发抽屉callback回调
Declaration
Swift
@MainActor open func setPosition(at index: Int, animated: Bool = true)
-
如果scrollView已自定义delegate,需在scrollViewDidScroll手工调用本方法
Declaration
Swift
@MainActor open func scrollViewDidScroll(_ scrollView: UIScrollView)
-
Undocumented
Declaration
Swift
@MainActor open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool