In our ios application normally text field text comes just after text field edge.But if you want to give space after text field and then display text you have to give.If you want to give 5 pixel gap from x position and 7 pixel from the y poistion of text field edge ,you can get this way:
.h file
#import <UIKit/UIKit.h>
@interface UITextFieldCustom : UITextField
@end
.m file
#import "UITextFieldCustom.h"
@implementation UITextFieldCustom
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 5 , 7 );
}
// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
return CGRectInset( bounds , 5 , 7 );
}
@end
whenever you put textfield in xib give its UITextFieldCustom
No comments:
Post a Comment