Skip to content

Instantly share code, notes, and snippets.

@ClintChil
Forked from RichFell/gist:c5f7bb56891b94542b02
Last active August 29, 2015 14:23
Show Gist options
  • Save ClintChil/62cb755c72851d0b40f2 to your computer and use it in GitHub Desktop.
Save ClintChil/62cb755c72851d0b40f2 to your computer and use it in GitHub Desktop.
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillChangeFrameNotification object:nil queue:nil usingBlock:^(NSNotification *note) {
NSDictionary *dict = [note userInfo];
NSValue *keyboardFrame = dict[UIKeyboardFrameEndUserInfoKey];
CGRect frame = [keyboardFrame CGRectValue];
NSNumber *duration = dict[UIKeyboardAnimationDurationUserInfoKey];
double durationDouble = [duration doubleValue];
[UIView animateWithDuration:durationDouble animations:^{
self.view.frame = CGRectMake(0, frame.origin.y - self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);
}];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment