
How to create UITextField Programmatically in iPhone?

How to create UITextField Programmatically
CGRect frame = CGRectMake(0, 0, 160, 29); UITextField *search= [[UITextField alloc] initWithFrame:frame]; search.borderStyle = UITextBorderStyleRoundedRect; search.textColor = [UIColor blackColor]; search.font = [UIFont systemFontOfSize:17.0]; search.placeholder = @"Suchen"; search.backgroundColor = [UIColor clearColor]; search.autocorrectionType = UITextAutocorrectionTypeNo; search.keyboardType = UIKeyboardTypeDefault; search.returnKeyType = UIReturnKeySearch; search.clearButtonMode = UITextFieldViewModeWhileEditing; search.delegate = self; UIImageView *myView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"searchiCon.png"]]; [search setRightView:myView]; [search setRightViewMode:UITextFieldViewModeAlways]; [myView release]; // and add it to the toolbar as bar button item, if you wanted to use it as search field. UIBarButtonItem *textFieldItem = [[UIBarButtonItem alloc] initWithCustomView:search];
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.