File tree Expand file tree Collapse file tree 4 files changed +30
-17
lines changed
FloatingViewDemo/FloatingViewDemo Expand file tree Collapse file tree 4 files changed +30
-17
lines changed Original file line number Diff line number Diff line change @@ -117,11 +117,11 @@ extension ViewController3: UITextFieldDelegate {
117117
118118// MARK: - FloatingViewDelegate
119119extension ViewController3 : FloatingViewDelegate {
120- func floatingViewDidBeginDragging( _ floatingView : ( UIView & FloatingViewProtocol ) ) {
120+ func floatingViewDidBeginDragging( panGestureRecognizer : UIPanGestureRecognizer ) {
121121 floatingView. alpha = 1
122122 }
123123
124- func floatingViewFinishedPartiallyHideAnimation( _ floatingView : ( UIView & FloatingViewProtocol ) ) {
124+ func floatingViewFinishedPartiallyHideAnimation( ) {
125125 floatingView. alpha = 0.5
126126 }
127127}
Original file line number Diff line number Diff line change 331 . 支持拖动、自动吸附、吸附后部分隐藏
442 . 支持自定义可吸附的 edges
553 . 支持自定义水平和纵向吸附的优先级
6- 4 . 支持自定义悬浮视图可到达区域
7- 5 . 支持自定义添加到` UIView ` 子类或者本库提供的` keyWindow ` 上
6+ 4 . 支持自定义开始吸附的最小距离
7+ 5 . 支持自定义悬浮视图可到达区域
8+ 6 . 支持自定义添加到` UIView ` 子类或者本库提供的` keyWindow ` 上
89
910# 环境要求
1011
@@ -84,4 +85,16 @@ floatingView.makeFloatingWindowKeyAndVisible()
8485
8586``` swift
8687floatingView.updateFloatingWindowStatusBarStyle (to : default )
87- ```
88+ ```
89+
90+ # 代理
91+
92+ 在悬浮视图开始拖动、结束拖动、拖动中和完成部分隐藏动画时,分别有以下代理方法:
93+
94+ ``` swift
95+ func floatingViewDidBeginDragging (panGestureRecognizer : UIPanGestureRecognizer)
96+ func floatingViewDidEndDragging (panGestureRecognizer : UIPanGestureRecognizer)
97+ func floatingViewDidMove (panGestureRecognizer : UIPanGestureRecognizer)
98+ func floatingViewFinishedPartiallyHideAnimation ()
99+ ```
100+
Original file line number Diff line number Diff line change 99import UIKit
1010
1111public protocol FloatingViewDelegate : NSObjectProtocol {
12- func floatingViewDidBeginDragging( _ floatingView : ( UIView & FloatingViewProtocol ) )
13- func floatingViewDidEndDragging( _ floatingView : ( UIView & FloatingViewProtocol ) )
14- func floatingViewDidMove( _ floatingView : ( UIView & FloatingViewProtocol ) )
15- func floatingViewFinishedPartiallyHideAnimation( _ floatingView : ( UIView & FloatingViewProtocol ) )
12+ func floatingViewDidBeginDragging( panGestureRecognizer : UIPanGestureRecognizer )
13+ func floatingViewDidEndDragging( panGestureRecognizer : UIPanGestureRecognizer )
14+ func floatingViewDidMove( panGestureRecognizer : UIPanGestureRecognizer )
15+ func floatingViewFinishedPartiallyHideAnimation( )
1616}
1717
1818public extension FloatingViewDelegate {
19- func floatingViewDidBeginDragging( _ floatingView : ( UIView & FloatingViewProtocol ) ) { }
20- func floatingViewDidEndDragging( _ floatingView : ( UIView & FloatingViewProtocol ) ) { }
21- func floatingViewDidMove( _ floatingView : ( UIView & FloatingViewProtocol ) ) { }
22- func floatingViewFinishedPartiallyHideAnimation( _ floatingView : ( UIView & FloatingViewProtocol ) ) { }
19+ func floatingViewDidBeginDragging( panGestureRecognizer : UIPanGestureRecognizer ) { }
20+ func floatingViewDidEndDragging( panGestureRecognizer : UIPanGestureRecognizer ) { }
21+ func floatingViewDidMove( panGestureRecognizer : UIPanGestureRecognizer ) { }
22+ func floatingViewFinishedPartiallyHideAnimation( ) { }
2323}
Original file line number Diff line number Diff line change @@ -43,17 +43,17 @@ public extension UIView {
4343
4444 switch pan. state {
4545 case . began:
46- floatingDelegate? . floatingViewDidBeginDragging ( view )
46+ floatingDelegate? . floatingViewDidBeginDragging ( panGestureRecognizer : pan )
4747 case . changed:
4848 defer {
4949 pan. setTranslation ( . zero, in: self )
5050 }
5151 let translation = pan. translation ( in: self )
5252 modifyOrigin ( withTranslation: translation)
53- floatingDelegate? . floatingViewDidMove ( view )
53+ floatingDelegate? . floatingViewDidMove ( panGestureRecognizer : pan )
5454 case . ended:
5555 animateToAdsorb ( )
56- floatingDelegate? . floatingViewDidEndDragging ( view )
56+ floatingDelegate? . floatingViewDidEndDragging ( panGestureRecognizer : pan )
5757 default : break
5858 }
5959 }
@@ -165,7 +165,7 @@ public extension UIView {
165165 UIView . animate ( withDuration: view. partiallyHideAnimationDuration, animations: {
166166 self . frame. origin = destinationOrigin
167167 } ) { isFinished in
168- self . floatingDelegate? . floatingViewFinishedPartiallyHideAnimation ( view )
168+ self . floatingDelegate? . floatingViewFinishedPartiallyHideAnimation ( )
169169 }
170170 }
171171}
You can’t perform that action at this time.
0 commit comments