这个问题,在很早之前都有,一般很少出现,但是iOS 10后,系统字体变大了,导致这个问题出现次数多了;
网上搜索了一些答案,下面我列一下别人和我自己项目中的解决方法:
方案一:(我自己项目中解决方法)
1.调整UITextField的样式,外框尽量的大些,防止遮住字,然后选择style,如图所示:

2.然后在代码中需要将border外框去掉
[objc] view plain copy [self.textField.subviews[0] removeFromSuperview];
方案二:(对于切换后台后切换回来导致的光标下移问题是有效的)
[html] view plain copy self.automaticallyAdjustsScrollViewInsets = NO; 方案三:(我项目中没卵用)
[html] view plain copy textField.clearButtonMode = UITextFieldViewModeWhileEditing; 方案四:(写个继承 UITextField 的类,然后重写下面方法,里面的frame根据需求改变,也是在我项目中没卵用)
[objc] view plain copy - (CGRect)textRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 2, 1); } - (CGRect)editingRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 2, 1); }