Skip to content

Commit

Permalink
Animate scroll view inset changes along with keyboard animation
Browse files Browse the repository at this point in the history
  • Loading branch information
darrarski committed Apr 8, 2014
1 parent 47e5ef0 commit 6dd2302
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions EKKeyboardAvoiding/EKKeyboardAvoidingProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ - (void)resetAvoidingContentInset

- (void)applyAvoidingContentInset:(UIEdgeInsets)avoidingInset
{
[[self scrollView] setContentInset:avoidingInset];
[[self scrollView] setScrollIndicatorInsets:avoidingInset];
NSTimeInterval animationDuration = [self.keyboardListener.keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:animationDuration animations:^{
[[self scrollView] setContentInset:avoidingInset];
[[self scrollView] setScrollIndicatorInsets:avoidingInset];
}];
}

- (UIEdgeInsets)calculateExtraContentInset
Expand Down
3 changes: 3 additions & 0 deletions EKKeyboardAvoiding/EKKeyboardFrameListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
/// Last observed keyboard frame
@property (nonatomic,readonly) CGRect keyboardFrame;

/// Last observed keyboard change info
@property (nonatomic,strong,readonly) NSDictionary *keyboardInfo;

@end
2 changes: 1 addition & 1 deletion EKKeyboardAvoiding/EKKeyboardFrameListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (CGRect)convertedKeyboardFrameForView:(UIView *)view

- (void)startNotificationsObseving
{
[self observeNotificationNamed:UIKeyboardDidChangeFrameNotification
[self observeNotificationNamed:UIKeyboardWillChangeFrameNotification
action:@selector(keyboardDidChangeFrame:)];
}

Expand Down

0 comments on commit 6dd2302

Please sign in to comment.