Skip to content

jiutianhuanpei/CustomKeyboradToolView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CustomKeyboradToolView

获取弹出键盘高度, 定义浮在键盘上的工具条

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasHiddin:) name:UIKeyboardWillHideNotification object:nil];
- (void)keyboardWasShown:(NSNotification *)notif {
    CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat maxHeight = [UIScreen mainScreen].bounds.size.height;
    NSDictionary *info = [notif userInfo];
    
    NSNumber *duration = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
    NSValue *value = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGSize size = [value CGRectValue].size;
    
    [UIView beginAnimations:@"te" context:nil];
    [UIView setAnimationDuration:[duration doubleValue]];
    _toolView.frame = CGRectMake(0, maxHeight - size.height - 50, maxWidth, 50);

    [UIView commitAnimations];
    

}

- (void)keyboardWasHiddin:(NSNotification *)notif {
    CGFloat maxWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat maxHeight = [UIScreen mainScreen].bounds.size.height;
    NSDictionary *info = [notif userInfo];
    
    NSNumber *duration = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];

    
    [UIView beginAnimations:@"re" context:nil];
    [UIView setAnimationDuration:[duration doubleValue]];
    _toolView.frame = CGRectMake(0, maxHeight - 50, maxWidth, 50);
    [UIView commitAnimations];
}

About

获取弹出键盘高度, 定义浮在键盘上的工具条

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published