You should use the keyboardWillShow : notification to customize other presentation frames.
A notification is sent to keyboardWillShow : not only to becomeFirstResponder for the text field / field, but also when the user shows / hides the keyboard of a quick type.
after the keyboardWillShow : notification is sent, the keyboard frame can be captured by UIKeyboardFrameEndUserInfoKey in the notification object.
An example of a textView that adjusts its frame based on the keyboard:
- (void)keyboardWillShow:(NSNotification *)notification { CGRect keyboardRect = [[[notification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; UIViewAnimationCurve curve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]; [UIView animateWithDuration:duration animations:^{ [UIView setAnimationCurve:curve]; self.textViewVisualEffectView.frame = CGRectMake(self.textViewVisualEffectView.origin.x, self.view.height - keyboardRect.size.height - self.textViewVisualEffectView.height, self.textViewVisualEffectView.width, self.textViewVisualEffectView.height); } completion:^(BOOL finished) { }]; }
source share