改变UITextField中的系统控件的大小及位置

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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

转载于:https://my.oschina.net/daxiaLKS/blog/727259

你可能感兴趣的:(改变UITextField中的系统控件的大小及位置)