본문 바로가기

Development/IOS & Mac

[iOS] UITextField Padding 값주기

헤더

@interface UITextField (Padding) {

}//end Variables


-(void) setLeftPadding:(int) paddingValue;

-(void) setRightPadding:(int) paddingValue;


@end


구현 부

@implementation UITextField (Padding)


-(void) setLeftPadding:(int) paddingValue {

    

UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, paddingValue, self.frame.size.height)];

    self.leftView = paddingView;

    self.leftViewMode = UITextFieldViewModeAlways;

}//end setLeftPadding Method


-(void) setRightPadding:(int) paddingValue {

    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, paddingValue, self.frame.size.height)];

    self.rightView = paddingView;

    self.rightViewMode = UITextFieldViewModeAlways;

}//end setRightPadding Method


@end