File tree Expand file tree Collapse file tree
KeyboardLayoutGuide/KeyboardLayoutGuide Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99import UIKit
1010
11+ private class Keyboard {
12+ static let shared = Keyboard ( )
13+ var currentHeight : CGFloat = 0
14+ }
15+
1116public extension UIView {
1217
1318 private struct AssociatedKeys {
@@ -52,10 +57,10 @@ open class KeyboardLayoutGuide: UILayoutGuide {
5257 return
5358 }
5459 NSLayoutConstraint . activate ( [
55- heightAnchor. constraint ( equalToConstant: 0 ) ,
60+ heightAnchor. constraint ( equalToConstant: Keyboard . shared . currentHeight ) ,
5661 leftAnchor. constraint ( equalTo: view. leftAnchor) ,
5762 rightAnchor. constraint ( equalTo: view. rightAnchor) ,
58- ] )
63+ ] )
5964 let viewBottomAnchor : NSLayoutYAxisAnchor
6065 if #available( iOS 11 . 0 , * ) {
6166 viewBottomAnchor = view. safeAreaLayoutGuide. bottomAnchor
@@ -73,6 +78,7 @@ open class KeyboardLayoutGuide: UILayoutGuide {
7378 }
7479 heightConstraint? . constant = height
7580 animate ( note)
81+ Keyboard . shared. currentHeight = height
7682 }
7783 }
7884
You can’t perform that action at this time.
0 commit comments