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);
    
            }];
    
        }
    
    }
  • 相关阅读:
    Linux中的防火墙
    Jinja2模板概述
    Ansible触发器-tag标签-忽略错误
    Ansible流程控制
    Ansible变量
    Play-book格式写法
    Redis哨兵(Sentinel)
    Redis 主从复制
    Redis介绍及安装
    Keepalived高可用集群搭建
  • 原文地址:https://www.cnblogs.com/lrr0618/p/6119177.html
Copyright © 2011-2022 走看看