• 键盘上升下降


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

    - (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));

        }];

    }

  • 相关阅读:
    EV: There is no source code available for the current location.
    EV: 致新教育萤火虫父母们
    DEL: 2012年每月花销
    DEL: 博客分类规则
    java编程规范
    maven随笔
    JMS组成结构与特点
    activemq 的简单使用
    activeMQ安装与访问
    java8 stream
  • 原文地址:https://www.cnblogs.com/danMing-love/p/7079728.html
Copyright © 2020-2023  润新知