Skip to content

Commit

Permalink
Merge pull request #9 from freshOS/iOS11Fix
Browse files Browse the repository at this point in the history
Fixes iOS 11 issue
  • Loading branch information
s4cha authored Dec 12, 2017
2 parents 10d84e1 + 70c1c55 commit 42485f9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

import UIKit

private class Keyboard {
static let shared = Keyboard()
var currentHeight: CGFloat = 0
}

public extension UIView {

private struct AssociatedKeys {
Expand Down Expand Up @@ -52,10 +57,10 @@ open class KeyboardLayoutGuide: UILayoutGuide {
return
}
NSLayoutConstraint.activate([
heightAnchor.constraint(equalToConstant: 0),
heightAnchor.constraint(equalToConstant: Keyboard.shared.currentHeight),
leftAnchor.constraint(equalTo: view.leftAnchor),
rightAnchor.constraint(equalTo: view.rightAnchor),
])
])
let viewBottomAnchor: NSLayoutYAxisAnchor
if #available(iOS 11.0, *) {
viewBottomAnchor = view.safeAreaLayoutGuide.bottomAnchor
Expand All @@ -73,6 +78,7 @@ open class KeyboardLayoutGuide: UILayoutGuide {
}
heightConstraint?.constant = height
animate(note)
Keyboard.shared.currentHeight = height
}
}

Expand Down

0 comments on commit 42485f9

Please sign in to comment.