File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
KeyboardLayoutGuide/KeyboardLayoutGuide Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import UIKit
10
10
11
+ private class Keyboard {
12
+ static let shared = Keyboard ( )
13
+ var currentHeight : CGFloat = 0
14
+ }
15
+
11
16
public extension UIView {
12
17
13
18
private struct AssociatedKeys {
@@ -52,10 +57,10 @@ open class KeyboardLayoutGuide: UILayoutGuide {
52
57
return
53
58
}
54
59
NSLayoutConstraint . activate ( [
55
- heightAnchor. constraint ( equalToConstant: 0 ) ,
60
+ heightAnchor. constraint ( equalToConstant: Keyboard . shared . currentHeight ) ,
56
61
leftAnchor. constraint ( equalTo: view. leftAnchor) ,
57
62
rightAnchor. constraint ( equalTo: view. rightAnchor) ,
58
- ] )
63
+ ] )
59
64
let viewBottomAnchor : NSLayoutYAxisAnchor
60
65
if #available( iOS 11 . 0 , * ) {
61
66
viewBottomAnchor = view. safeAreaLayoutGuide. bottomAnchor
@@ -73,6 +78,7 @@ open class KeyboardLayoutGuide: UILayoutGuide {
73
78
}
74
79
heightConstraint? . constant = height
75
80
animate ( note)
81
+ Keyboard . shared. currentHeight = height
76
82
}
77
83
}
78
84
You can’t perform that action at this time.
0 commit comments