我想在我的iPhone应用中的UITextField
放置临时文字。 Android具有提示属性以在文本字段中显示临时文本。我如何在iPhone开发中做同样的事情?
答案 0 :(得分:7)
UITextFields有一个Placeholder属性,可以让你设置提示文本:
MyTextField.Placeholder = "Required";
答案 1 :(得分:1)
UITextfield使用占位符有不同的方法,下面给出了一些好的方法
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;