iOS虚拟键盘上添加动态按钮(2)
[[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
NSValue *animationDurValue = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
// copy value
[animationDurValue getValue:&animationDuration];
// 让键盘弹起的时候添加一个动画
[UIView beginAnimations:@"animal" context:nil];
[UIView setAnimationDuration:animationDuration];
CGFloat distanceToMove = kbSize.height;
NSLog(@"---->动态键盘高度:%f",distanceToMove);
[self adjustPanelsWithKeyBordHeight:distanceToMove];
[UIView commitAnimations];
exitButton.hidden=NO;
[exitButton addTarget:self action:@selector(CancelBackKeyboard:) forControlEvents:UIControlEventTouchDown];
}
- (void)handleKeyboardWillHide:(NSNotification *)notification
{
NSLog(@"%@",NSStringFromSelector(_cmd));
NSDictionary *info = [notification userInfo];
CGRect keyboardFrame;
[[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
NSValue *animationDurValue = [info objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
// 把animationDurvalue 值拷贝到animationDuration中
[animationDurValue getValue:&animationDuration];
[UIView beginAnimations:@"animal" context:nil];
[UIView setAnimationDuration:animationDuration];
if (exitButton) {
CGRect exitBtFrame = CGRectMake(self.view.frame.size.width - 48, self.view.frame.size.height, 48.0f, 30.0f);
exitButton.frame = exitBtFrame;
[self.view addSubview:exitButton];
}
[UIView commitAnimations];
}
-(void)adjustPanelsWithKeyBordHeight:(float) height
{
NSLog(@"%@",NSStringFromSelector(_cmd));
if (exitButton) {
CGRect exitBtFrame = CGRectMake(self.view.frame.size.width - 48, self.view.frame.size.height - height-30, 48.0f, 30.0f);
exitButton.frame = exitBtFrame;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>