func keyBoardWillShow(_ note:Notification)
{
if (note as NSNotification).userInfo == nil{
return
}
let userInfo = (note as NSNotification).userInfo! as NSDictionary
let keyBoardBounds = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
let deltaY = keyBoardBounds.size.height
self.inputeDefaultView.isHidden = false
self.view.bringSubview(toFront: self.inputeDefaultView)
let animations:(() -> Void) = {
self.inputeDefaultView.transform = CGAffineTransform(translationX: 0,y: -deltaY)
}
if duration > 0 {
let options = UIViewAnimationOptions(rawValue: UInt((userInfo[UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).intValue << 16))
UIView.animate(withDuration: duration, delay: 0, options:options, animations: animations, completion: nil)
}else{
animations()
}
}
func keyBoardWillHide(_ note:Notification)
{
if (note as NSNotification).userInfo == nil{
return
}
let userInfo = (note as NSNotification).userInfo! as NSDictionary
let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
let animations:(() -> Void) = {
self.inputeDefaultView.transform = CGAffineTransform.identity
}
if duration > 0 {
let options = UIViewAnimationOptions(rawValue: UInt((userInfo[UIKeyboardAnimationCurveUserInfoKey] as! NSNumber).intValue << 16))
UIView.animate(withDuration: duration, delay: 0, options:options, animations: animations, completion: nil)
UIView.animate(withDuration: duration, delay: 0, options: options, animations: animations, completion: { [weak self](bool) in
if let weakSelf = self{
weakSelf.inputeDefaultView.isHidden = true
}
})
}else{
animations()
}
}