Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Created May 22, 2018 01:20
Show Gist options
  • Save alexpaul/d2d9b949bc875e20076d8fed435876a8 to your computer and use it in GitHub Desktop.
Save alexpaul/d2d9b949bc875e20076d8fed435876a8 to your computer and use it in GitHub Desktop.
#pragma mark Keyboard Handling
- (void)registerForKeyboardNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillShow: (NSNotification *)notification {
NSDictionary *userInfo = [notification userInfo];
CGSize size = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
self.tipView.transform = CGAffineTransformMakeTranslation(0, -size.height);
}
- (void)keyboardWillHide: (NSNotification *)notification {
self.tipView.transform = CGAffineTransformIdentity;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment