Skip to content

Instantly share code, notes, and snippets.

@gazolla
Created June 20, 2016 01:05
Show Gist options
  • Save gazolla/4a44169c4af08feb5356f0f8d55ccaf8 to your computer and use it in GitHub Desktop.
Save gazolla/4a44169c4af08feb5356f0f8d55ccaf8 to your computer and use it in GitHub Desktop.
Programmatically create UITextField
let sampleTextField = UITextField(frame: CGRectMake(20, 100, 300, 40))
sampleTextField.placeholder = "Enter text here"
sampleTextField.font = UIFont.systemFontOfSize(15)
sampleTextField.borderStyle = UITextBorderStyle.RoundedRect
sampleTextField.autocorrectionType = UITextAutocorrectionType.No
sampleTextField.keyboardType = UIKeyboardType.Default
sampleTextField.returnKeyType = UIReturnKeyType.Done
sampleTextField.clearButtonMode = UITextFieldViewMode.WhileEditing;
sampleTextField.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
sampleTextField.delegate = self
self.view.addSubview(sampleTextField)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment