zoukankan      html  css  js  c++  java
  • 键盘上升下降

    //当键盘出现或改变时调用

    - (void)keyboardWillShow:(NSNotification *)aNotification

    {

        NSDictionary *userInfo = [aNotification userInfo];

        NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

        CGRect keyboardRect = [aValue CGRectValue];

        CGFloat height = keyboardRect.size.height;

        CGFloat offset = CGRectGetMaxY(self.urlInput.frame) + 10 - (CGRectGetMaxY(self.view.bounds) - height);

        

        NSNumber *durationNum = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];

        CGFloat duration = [durationNum floatValue];

        

        if (offset > 0)

        {

            [UIView animateWithDuration:duration animations:^{

                self.view.frame = CGRectMake(0,-offset, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));

            }];

        }

    }

    //当键退出时调用

    - (void)keyboardWillHide:(NSNotification *)aNotification

    {

        NSDictionary *userInfo = [aNotification userInfo];

        NSNumber *durationNum = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];

        CGFloat duration = [durationNum floatValue];

        

        [UIView animateWithDuration:duration animations:^{

            self.view.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));

        }];

    }

  • 相关阅读:
    02-模板字符串
    01-学习vue前的准备工作
    21-z-index
    20-定位
    19-background
    18-超链接导航栏案例
    17-文本属性和字体属性
    16-margin的用法
    jBPM
    Table of Contents
  • 原文地址:https://www.cnblogs.com/danMing-love/p/7079728.html
Copyright © 2011-2022 走看看