zoukankan      html  css  js  c++  java
  • iOS

    #define KScreen_Bounds [UIScreen mainScreen].bounds
    #define KScreen_Size [UIScreen mainScreen].bounds.size
    #define KScreen_Width [UIScreen mainScreen].bounds.size.width
    #define KScreen_Height [UIScreen mainScreen].bounds.size.height
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        //添加通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardMiss:) name:UIKeyboardWillHideNotification object:nil];
    }
    
    • 实现通知方法:
    //回收键盘改变控制器view
    -(void)keyboardMiss:(NSNotification *)noti{
        self.view.frame = CGRectMake(0, 0, KScreen_Width, KScreen_Height);
    }
    // 弹出键盘改变控制器view
    -(void)keyboardShow:(NSNotification *)noti{
        CGRect keyboardRect = [[noti.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
        self.view.frame = CGRectMake(0, -keyboardRect.size.height, KScreen_Width, KScreen_Height);
    }
    
    • 点击屏幕回收键盘:
    -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
        [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    }
    
    
    • 最后效果没有做任何动画处理,感觉这样也挺线性的:
  • 相关阅读:
    Spring_Bean的配置方式
    Nginx Ingress设置账号密码
    2.2.4 加减运算与溢出
    2.2.5-2 补码乘法
    2.2.3 移位运算
    flask钩子函数
    flask的cookie、session
    循环冗余校验码
    海明校验码
    python中的 __call__()
  • 原文地址:https://www.cnblogs.com/adampei-bobo/p/7356413.html
Copyright © 2011-2022 走看看