• 键盘弹出


    cell.Projreview.layer.cornerRadius = 5;

        cell.AnmiProjiectView.layer.cornerRadius = 5;

        cell.Headimage.layer.cornerRadius = 20;

        cell.AnmHeadimage.layer.cornerRadius = 20;

        //cell.AnmHeadimage.clipsToBounds =YES;//将超出视图范围的图片切掉

        cell.AnmHeadimage.layer.masksToBounds = YES;

        cell.Headimage.clipsToBounds = YES;

     

    键盘回弹

    //开始编辑输入框的时候,软键盘出现,执行此事件

    -(void)textFieldDidBeginEditing:(UITextField *)textField

    {

        CGRect frame=textField.frame;

        int offset =frame.origin.y+32-(self.view.frame.size.height-216.0);//键盘高度216

        NSTimeInterval animationDuration=0.30f;

        [UIView beginAnimations:@"ResizeForKeyboard" context:nil];

        [UIView setAnimationDuration:animationDuration];

        //将视图的y坐标上移offset 个单位以便弹出地方用于键盘的显示

        if (offset>0) {

            self.view.frame=CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);

            [UIView commitAnimations];

        }

    }

    //engter键收回键盘

    - (BOOL)textFieldShouldReturn:(UITextField *)textField{

        [textField resignFirstResponder];

        return YES;

    }

    //输入结束, 弹回键盘

    -(void)textFieldDidEndEditing:(UITextField *)textField

    {

        self.view.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

    }

    //点击屏幕, 收回键盘

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

        [self.view endEditing:YES];

    }

     

    //添加动画效果 

    -(void)animations:(BOOL)isshow{

        [self textFieldShouldReturn:searchTF];

        //开始动画

        [UIView beginAnimations:nil context:nil];

        //设定动画持续时间

        [UIView setAnimationDuration:.5];

        //动画的内容

  • 相关阅读:
    PAT乙级:1083 是否存在相等的差 (20分)
    PAT乙级:1082 射击比赛 (20分)
    PAT乙级:1084 外观数列 (20分)
    PAT乙级:1070 结绳 (25分)
    PAT乙级:1064 朋友数 (20分)
    JavaScript实现拖放效果
    Lesson2 Thirteen equals one
    PAT乙级:1076 Wifi密码 (15分)
    条件查询
    根据配置生成创始块文件和通道文件
  • 原文地址:https://www.cnblogs.com/CodingMann/p/4877901.html
Copyright © 2020-2023  润新知