如何大写首字母的文字

时间:2022-12-06 21:37:12

There is some text in a text field. Before setting it to txtfdName, I want to capitalize the first letter.

文本字段中有一些文本。在将其设置为txtfdName之前,我想将第一个字母大写。

[addrecipe.txtfdName setText:txtfield1.text];

6 个解决方案

#1


34  

Use autocapitalizationType for capital letter of UITextField.

使用autocapitalizationType作为UITextField的大写字母。

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

#2


14  

Use this code to capitalized first latter

使用此代码首先使用后者

NSString *abc = @"this is test";

abc = [NSString stringWithFormat:@"%@%@",[[abc substringToIndex:1] uppercaseString],[abc substringFromIndex:1] ];       
NSLog(@"abc = %@",abc);

#3


8  

To capitalize the first letter of each word manually in code:

要在代码中手动大写每个单词的第一个字母:

NSString* name = [addrecipe.txtfdName setText:txtfield1.text];
name = [name capitalizedString];

#4


5  

Use autocapitalizationType property of UITextInputTraits protocol which is conform by both UITextView and UITextField

使用UITextInputTraits协议的autocapitalizationType属性,该属性符合UITextView和UITextField

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

#5


4  

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

or you can also try

或者你也可以尝试

[addrecipe.txtfdName setText:[txtfield1.text capitalizedString]]; // the first character from each word in the receiver changed to its corresponding uppercase value

#6


1  

select txtfield1 and go to Attributes Inspector , there is a Capitalization with a drop down menu and select menu form Following

选择txtfield1并转到属性检查器,有一个带有下拉菜单的大写,并选择菜单表格

Word : if you select Word than first character of every word is Capital

单词:如果你选择Word而不是每个单词的第一个字符是Capital

Sentences : if you Sentence than first character of First word of every sentence is Capital

句子:如果你的句子比第一个字的每个句子的第一个字就是资本

All Characters : All Characters are Capital

所有角色:所有角色都是资本

#1


34  

Use autocapitalizationType for capital letter of UITextField.

使用autocapitalizationType作为UITextField的大写字母。

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

#2


14  

Use this code to capitalized first latter

使用此代码首先使用后者

NSString *abc = @"this is test";

abc = [NSString stringWithFormat:@"%@%@",[[abc substringToIndex:1] uppercaseString],[abc substringFromIndex:1] ];       
NSLog(@"abc = %@",abc);

#3


8  

To capitalize the first letter of each word manually in code:

要在代码中手动大写每个单词的第一个字母:

NSString* name = [addrecipe.txtfdName setText:txtfield1.text];
name = [name capitalizedString];

#4


5  

Use autocapitalizationType property of UITextInputTraits protocol which is conform by both UITextView and UITextField

使用UITextInputTraits协议的autocapitalizationType属性,该属性符合UITextView和UITextField

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

#5


4  

txtfield1.autocapitalizationType = UITextAutocapitalizationTypeWords;

or you can also try

或者你也可以尝试

[addrecipe.txtfdName setText:[txtfield1.text capitalizedString]]; // the first character from each word in the receiver changed to its corresponding uppercase value

#6


1  

select txtfield1 and go to Attributes Inspector , there is a Capitalization with a drop down menu and select menu form Following

选择txtfield1并转到属性检查器,有一个带有下拉菜单的大写,并选择菜单表格

Word : if you select Word than first character of every word is Capital

单词:如果你选择Word而不是每个单词的第一个字符是Capital

Sentences : if you Sentence than first character of First word of every sentence is Capital

句子:如果你的句子比第一个字的每个句子的第一个字就是资本

All Characters : All Characters are Capital

所有角色:所有角色都是资本