1

I'd like to place temporary text in the UITextField on my iPhone app. Android has the hint property to display temporary text in the textfield. How do I do the same in iPhone development?

Adrian Wragg
  • 7,311
  • 3
  • 26
  • 50
Yahiko Kikikoto
  • 688
  • 3
  • 12
  • 23

2 Answers2

7

UITextFields have a Placeholder property that let you set the hint text:

MyTextField.Placeholder = "Required";
Ben Bishop
  • 1,414
  • 9
  • 14
1

There are different approaches to used place holder for UITextfield some good way given below

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;
  1. link 1
  2. link 2
  3. link 3

I hope it helps you.Thanks

Community
  • 1
  • 1
jamil
  • 2,419
  • 3
  • 37
  • 64