iOS UITextView 隨鍵盤彈出介面上移
阿新 • • 發佈:2019-02-11
- (void)textViewDidBeginEditing:(UITextView *)textView {
CGRect frame = textView.frame;
int offSet = frame.origin.y + 70 - (self.view.frame.size.height - 216.0); //iphone鍵盤高度為216.iped鍵盤高度為352
[UIView beginAnimations:@"ResizeForKeyboard"context:nil];
[UIView setAnimationDuration:0.5f];
//將試圖的Y座標向上移動offset個單位,以使線面騰出開的地方用於軟鍵盤的顯示
if (offSet > 0) {
self.view.frame = CGRectMake(0.0f, -offSet, self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
- (void)textViewDidEndEditing:(UITextView *)textView {
self.view.frame = CGRectMake(
}