UITextField align left margin

如果我们想让我们的UITextField输入的字体偏移几个像素,我们常常用空格来代替,有时候我们不想用空格的话怎么办?

#import <UIKit/UIKit.h>


@interface MYTextField : UITextField


@end




@implementation MYTextField


- (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



posted on 2013-08-14 19:06  you Richer  阅读(274)  评论(0)    收藏  举报