zoukankan      html  css  js  c++  java
  • iOS 自定义键盘ToolBar(与键盘的弹出、收起保持一致)

    1、监听键盘改变的通知

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];

      

    2、实现通知方法

    /**
    
     *  给键盘的frame改变添加监听
    
     *  @param keyBoardWillChangeFrame: 监听方法
    
     */
    
    - (void)keyBoardWillChangeFrame:(NSNotification*)notification{
    
        // 键盘显示隐藏完毕的frame
    
        CGRect frame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
        // 动画时间
    
        CGFloat duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    
        if (frame.origin.y == JYEScreenHeight) { // 没有弹出键盘
    
            [UIView animateWithDuration:duration animations:^{
    
                self.toolBarView.transform =  CGAffineTransformIdentity;
    
            }];
    
        }else{ // 弹出键盘
    
            // 工具条往上移动258
    
            [UIView animateWithDuration:duration animations:^{
    
                self.toolBarView.transform = CGAffineTransformMakeTranslation(0, -frame.size.height-64);
    
            }];
    
        }
    
    }
  • 相关阅读:
    整数子数组求最大和
    四则运算实现
    四则运算
    2015年大二下学期读书计划
    java变量和数据类型
    jdk的安装和java的入门概念
    数据库的设计
    多表查询
    数据约束和外键
    表数据的简单查询语句
  • 原文地址:https://www.cnblogs.com/lrr0618/p/6119177.html
Copyright © 2011-2022 走看看