Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @objc func keyboardWillShow(_ notification: NSNotification) {
- let keyboardAnimationDetail = notification.userInfo
- let animationCurve: Int = {
- if let keyboardAnimationCurve = keyboardAnimationDetail?[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int {
- let curve: Int? = UIView.AnimationCurve(rawValue: keyboardAnimationCurve)?.rawValue
- return curve ?? 0
- } else {
- return 0
- }
- }()
- let duration: Double = {
- if let animationDuration = keyboardAnimationDetail?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Int {
- return Double(animationDuration)
- } else {
- return 0
- }
- }()
- let options = UIView.AnimationOptions(rawValue: ((UInt(animationCurve << 16))))
- let translate = CGAffineTransform(translationX: 0, y: -80)
- UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
- self.closeButtonUI.alpha = 0
- self.buttonsStackView.isHidden = true
- self.wrapperView.transform = translate
- self.buttonsStackView.layoutIfNeeded()
- }, completion: { _ in
- })
- }
- @objc func keyboardWillHide(_ notification: NSNotification) {
- let keyboardAnimationDetail = notification.userInfo
- let animationCurve: Int = {
- if let keyboardAnimationCurve = keyboardAnimationDetail?[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int {
- let curve: Int? = UIView.AnimationCurve(rawValue: keyboardAnimationCurve)?.rawValue
- return curve ?? 0
- } else {
- return 0
- }
- }()
- let duration: Double = {
- if let animationDuration = keyboardAnimationDetail?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Int {
- return Double(animationDuration)
- } else {
- return 0
- }
- }()
- let options = UIView.AnimationOptions(rawValue: ((UInt(animationCurve << 16))))
- let translate = CGAffineTransform.identity
- UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
- self.closeButtonUI.alpha = 1
- self.buttonsStackView.isHidden = false
- self.wrapperView.transform = translate
- self.buttonsStackView.layoutIfNeeded()
- }, completion: { _ in
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement