SHARE
TWEET

Untitled

a guest Jun 25th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @objc func keyboardWillShow(_ notification: NSNotification) {
  2.         let keyboardAnimationDetail = notification.userInfo
  3.        
  4.         let animationCurve: Int = {
  5.             if let keyboardAnimationCurve = keyboardAnimationDetail?[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int {
  6.                 let curve: Int? = UIView.AnimationCurve(rawValue: keyboardAnimationCurve)?.rawValue
  7.                 return curve ?? 0
  8.             } else {
  9.                 return 0
  10.             }
  11.         }()
  12.        
  13.         let duration: Double = {
  14.             if let animationDuration = keyboardAnimationDetail?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Int {
  15.                 return Double(animationDuration)
  16.             } else {
  17.                 return 0
  18.             }
  19.         }()
  20.        
  21.         let options = UIView.AnimationOptions(rawValue: ((UInt(animationCurve << 16))))
  22.    
  23.         let translate = CGAffineTransform(translationX: 0, y: -80)
  24.        
  25.        
  26.        
  27.         UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
  28.             self.closeButtonUI.alpha = 0
  29.            
  30.             self.buttonsStackView.isHidden = true
  31.            
  32.             self.wrapperView.transform = translate
  33.             self.buttonsStackView.layoutIfNeeded()
  34.         }, completion: { _ in
  35.         })
  36.     }
  37.    
  38.     @objc func keyboardWillHide(_ notification: NSNotification) {
  39.         let keyboardAnimationDetail = notification.userInfo
  40.        
  41.         let animationCurve: Int = {
  42.             if let keyboardAnimationCurve = keyboardAnimationDetail?[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int {
  43.                 let curve: Int? = UIView.AnimationCurve(rawValue: keyboardAnimationCurve)?.rawValue
  44.                 return curve ?? 0
  45.             } else {
  46.                 return 0
  47.             }
  48.         }()
  49.        
  50.         let duration: Double = {
  51.             if let animationDuration = keyboardAnimationDetail?[UIResponder.keyboardAnimationDurationUserInfoKey] as? Int {
  52.                 return Double(animationDuration)
  53.             } else {
  54.                 return 0
  55.             }
  56.         }()
  57.        
  58.         let options = UIView.AnimationOptions(rawValue: ((UInt(animationCurve << 16))))
  59.        
  60.         let translate = CGAffineTransform.identity
  61.        
  62.        
  63.        
  64.         UIView.animate(withDuration: duration, delay: 0, options: options, animations: {
  65.             self.closeButtonUI.alpha = 1
  66.            
  67.             self.buttonsStackView.isHidden = false
  68.            
  69.             self.wrapperView.transform = translate
  70.             self.buttonsStackView.layoutIfNeeded()
  71.         }, completion: { _ in
  72.         })
  73.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top