Skip to content

Instantly share code, notes, and snippets.

@maojj
Created April 5, 2013 12:29
Show Gist options
  • Save maojj/5318939 to your computer and use it in GitHub Desktop.
Save maojj/5318939 to your computer and use it in GitHub Desktop.
keyboard animation
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary *info = [notification userInfo];
NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGFloat duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue];
CGSize keyboardSize = [aValue CGRectValue].size;
CGRect viewFrame = CGRectMake(0,
0,
UI_SCREEN_WIDTH,
self.View.frame.size.height - keyboardSize.height);
[UIView animateWithDuration:duration animations:^{
self.view.frame = viewFrame;
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment