以下是三種可選的解決方法:
1、把IB中的borderStyle換成UITextBorderStyleLine,在代碼中把其改成UITextBorderStyleNone
2、textField.clearButtonMode = UITextFieldViewModeWhileEditing;
3、繼承UITextField,覆蓋以下方法
- (CGRect)textRectForBounds:(CGRect)bounds {
? ? ? return CGRectInset(bounds,2,1);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
? ? ?return CGRectInset(bounds,2,1);
}