- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
+ (UIView *) createTextField:(NSString *)placeholder {
UIView * view = [UIView new];
view.frame = CGRectMake(0, 0, 100, 50);
view.autoresizesSubviews = YES;
view.backgroundColor = [UIColor whiteColor];
view.layer.borderWidth = 0.5;
view.layer.borderColor = COLOR(204, 204, 204).CGColor;
view.layer.cornerRadius = 5;
view.exclusiveTouch = YES;
UITextField * testField = [UITextField new];
testField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
testField.textColor = [UIColor blackColor];
testField.borderStyle = UITextBorderStyleNone;
testField.autocorrectionType = UITextAutocorrectionTypeNo;
[view addSubview:testField];
return view;
}
Потом у нас есть какойто контроллер
- (void)viewDidLoad {
[super viewDidLoad];
textField = [[MyClass createTextField:@"CITY, STATE OR ZIP"] subviews][0];
textField.returnKeyType = UIReturnKeySearch;
textField.delegate = (id<UITextFieldDelegate>)self;
[self.view addSubview:textField.superview];
}