Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created May 24, 2011 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save bsodmike/988751 to your computer and use it in GitHub Desktop.
Save bsodmike/988751 to your computer and use it in GitHub Desktop.
Adding a textfield programmatically to a view in IOS
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame = CGRectMake(300, 300, 200, 30);
UITextField *textField = [[UITextField alloc] initWithFrame:frame];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.textColor = [UIColor blackColor];
textField.font = [UIFont systemFontOfSize:17.0];
textField.placeholder = @"Suchen";
textField.backgroundColor = [UIColor clearColor];
textField.autocorrectionType = UITextAutocorrectionTypeYes;
textField.keyboardType = UIKeyboardTypeDefault;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.delegate = self;
[self.view addSubview:textField];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment