Created
December 15, 2013 00:45
-
-
Save mjjimenez/7967112 to your computer and use it in GitHub Desktop.
Animate scrolling to new content offset when keyboard appears in iOS 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[UIView beginAnimations:nil context:NULL]; | |
[UIView setAnimationDuration:[info[UIKeyboardAnimationDurationUserInfoKey] doubleValue]]; | |
[UIView setAnimationCurve:[info[UIKeyboardAnimationCurveUserInfoKey] integerValue]]; | |
[UIView setAnimationBeginsFromCurrentState:YES]; | |
self.textViewKeyboardConstraint.constant = height; | |
UIEdgeInsets insets = UIEdgeInsetsMake( | |
scrollView.contentInset.top, 0, textView.bounds.size.height + height, 0); | |
scrollView.contentInset = insets; | |
scrollView.scrollIndicatorInsets = insets; | |
[view layoutIfNeeded]; | |
[scrollView setContentOffset:CGPointMake(0, newOffset) animated:NO]; | |
[UIView commitAnimations]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment