IOS-UITextField重写文字区域to left、center、right、up、down in TextField
重写UITextField方法:
-(CGRect)textRectForBounds:(CGRect)bounds
;
效果如图:-------->
-(CGRect)editingRectForBounds:(CGRect)bounds
;
@interfaceMYTextField:UITextField
@end
@implementationMYTextField
-(CGRect)textRectForBounds:(CGRect)bounds {
int margin =10;
CGRect inset =CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
return inset;
}
-(CGRect)editingRectForBounds:(CGRect)bounds {
int margin =10;
CGRect inset =CGRectMake(bounds.origin.x + margin, bounds.origin.y, bounds.size.width - margin, bounds.size.height);
return inset;
}
@end