美文网首页
设置弹出键盘不遮挡输入框的方法

设置弹出键盘不遮挡输入框的方法

作者: Youthfulless | 来源:发表于2016-11-30 11:02 被阅读15次

#pragma mark 设置弹出键盘不遮挡输入框的方法

- (void)textFieldDidBeginEditing:(UITextField *)textField {

//    if (textField.tag==0) {

//        [self moveView:-23];

//    }

//    if (textField.tag==1)

//    {

//        [self moveView:-40];

//    }

}

- (void)textFieldDidEndEditing:(UITextField *)textField {

//    if (textField.tag == 0) {

//        [self moveView:23];

//    }

//    if (textField.tag == 1) {

//        [self moveView: 40];

//    }

}

-(void)moveView:(float)move{

NSTimeInterval animationDuration = 0.30f;

CGRect frame = self.view.frame;

frame.origin.y +=move;//view的X轴上移

self.view.frame = frame;

[UIViewbeginAnimations:@"ResizeView"context:nil];

[UIView setAnimationDuration:animationDuration];

self.view.frame = frame;

[UIViewcommitAnimations];//设置调整界面的动画效果

}

相关文章

网友评论

      本文标题:设置弹出键盘不遮挡输入框的方法

      本文链接:https://www.haomeiwen.com/subject/ncttmttx.html