Skip to content

Commit 42485f9

Browse files
authored
Merge pull request #9 from freshOS/iOS11Fix
Fixes iOS 11 issue
2 parents 10d84e1 + 70c1c55 commit 42485f9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
import UIKit
1010

11+
private class Keyboard {
12+
static let shared = Keyboard()
13+
var currentHeight: CGFloat = 0
14+
}
15+
1116
public 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

0 commit comments

Comments
 (0)