iOS虚拟键盘上添加动态按钮
之前在 在iOS虚拟键盘上添加动态隐藏按钮一文中描叙了关于键盘上添加动态按钮的操作,发现键盘上的按钮显示出来的时候很僵硬,此处做了改进,添加了动画过渡,更换了图片,能够让人感觉按钮是随着键盘的动画显示而显示,随着键盘的动画退出而退出,看上去更加流畅些;
效果图:
- (void)viewDidLoad
{
NSLog(@"%@",NSStringFromSelector(_cmd));
[super viewDidLoad];
exitButton = [UIButton buttonWithType:UIButtonTypeCustom];
[exitButton setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateNormal];
CGRect exitBtFrame = CGRectMake(self.view.frame.size.width-48, self.view.frame.size.height , 48.0f, 30.0f);
[exitButton setFrame:exitBtFrame];
[self.view addSubview:exitButton];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)handleKeyboardDidShow:(NSNotification *)notification
{
NSLog(@"%@",NSStringFromSelector(_cmd));
NSDictionary *info = [notification userInfo];
NSLog(@"-->info:%@",info);
CGRect keyboardFrame;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>