Skip to content

Instantly share code, notes, and snippets.

@matkuznik
Created May 18, 2021 13:15
Show Gist options
  • Save matkuznik/9bdee47f6393e31a93e0c85edd019e13 to your computer and use it in GitHub Desktop.
Save matkuznik/9bdee47f6393e31a93e0c85edd019e13 to your computer and use it in GitHub Desktop.
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey]
.flatMap { $0 as? Double } ?? 0.25
if duration > 0 {
let curve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey]
.flatMap { $0 as? Int }
.flatMap { UIView.AnimationCurve(rawValue: $0) } ?? .easeInOut
UIViewPropertyAnimator(duration: duration, curve: curve) {
viewController.view.layoutIfNeeded()
}
.startAnimation()
} else {
viewController.view.layoutIfNeeded()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment