Please let me know how to use this custom UITextField in my UIViewController
I am using storyboards.
#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;
}
Instead of using a normal
UITextField, you have to use your customMYTextField.In code:
If you use Interface Builder:
Select your
UITextFieldin your Interface Builder file, go to theIdentity Inspectorand set the correct sub class: