У меня есть textField и кнопка, которая связывается с Keyboard, но при попытке написать в textField кнопку disapper и при закрытии клавиатуры кнопку
я использую эту функцию
func bindToKeyboard(){
NotificationCenter.default.addObserver(self, selector: #selector(keybordWillChange), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
}
@objc func keybordWillChange(_ notification : NSNotification){
let duration = notification.userInfo![UIResponder.keyboardAnimationDurationUserInfoKey] as! Double
let curve = notification.userInfo![UIResponder.keyboardAnimationCurveUserInfoKey] as! UInt
let startingFrame = (notification.userInfo![UIResponder.keyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
let endingFrame = ( notification.userInfo![UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
let deltaY = endingFrame.origin.y - startingFrame.origin.y
UIView.animateKeyframes(withDuration: duration, delay:0.0, options: UIView.KeyframeAnimationOptions(rawValue: curve), animations: {
self.frame.origin.y += deltaY
print(deltaY)
}, completion: nil)
}
я делегирую текстовое поле в ViewDidload
pointsGoalTextField.delegate = self