下边输入框控件,可以重设输入框内部的显示区域,下边的两个函数必须重载,不能直接调用。
@interface DXUITextField : UITextField
@end
@implementation DXUITextField
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width-25, bounds.size.height);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width-25, bounds.size.height);
}
@end
本文介绍了一个自定义的 UITextField 子类 DXUITextField,通过重写 textRectForBounds 和 editingRectForBounds 方法来调整输入框的显示区域,使得输入框的内容区域相对于原始大小减少了25个单位的宽度。
1万+

被折叠的 条评论
为什么被折叠?



