Created
October 3, 2012 17:47
-
-
Save swarut/3828564 to your computer and use it in GitHub Desktop.
Objective-C : Custom UITextField with left padding, background and keyboard hiding on exit #objective-c #textfield #customtextfield #ui #hidekeyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "RoundedTextField.h" | |
@implementation RoundedTextField | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) { | |
} | |
[self configure]; | |
return self; | |
} | |
- (IBAction)hideKeyboard:(id)sender{ | |
[sender resignFirstResponder]; | |
} | |
- (void) configure{ | |
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; | |
self.leftView = paddingView; | |
self.leftViewMode = UITextFieldViewModeAlways; | |
[self addTarget:self action:@selector(hideKeyboard:) forControlEvents:UIControlEventEditingDidEndOnExit]; | |
[self setBackground:[UIImage imageNamed:@"iphone_textbox"]]; | |
[self setBorderStyle:UITextBorderStyleNone]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment