2019独角兽企业重金招聘Python工程师标准>>>
1.写一个继承于UITextField的子类,例如:SFCustomTextField;
2.在相应的重写方法中加入你想要的操作;
3.用SFCustomTextField创建相应的对象
#import "SFCustomTextField.h"
@implementation SFCustomTextField
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
-(CGRect)clearButtonRectForBounds:(CGRect)boundst
{
CGRect rect = [super clearButtonRectForBounds:boundst];
return CGRectOffset(rect, -10, 0);
}
- (CGRect)editingRectForBounds:(CGRect)bounds {
CGRect rect = [super editingRectForBounds:bounds];
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0 ,5);
return UIEdgeInsetsInsetRect(rect, insets);
}
@end