键盘弹出

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];

    //动画的内容

原文地址:https://www.cnblogs.com/CodingMann/p/4877901.html