IOS: Text correlation (18-01-22 more), ios18-01-22
0. Preface
1. Tips
UILabel class:
1-1-1). If you want to set a line spacing rich text with a ellipsis, you need to set it to be omitted again (the setting will expire during initialization ).
UITextField class:
1-2-1.
UITextView class:
1-3-1), UITextView can only be centered on the X axis, the Y axis needs to be manually adjusted.
UITextField and UITextView have the following classes:
1-4-1). A ToolBar with the "finish" button on the right is displayed on the keyboard.
1-4-2), Protocol UITextInputTraits (automatic upper case, error correction, keyboard-related ).
0. Preface
1. UILabel:
1. No built-in selection or replication function
2. No placeholders
3. Multiple rows
2. UITextField:
1,
2. There are placeholders
3. One row
3. UITextView:
1,
2. No placeholders
3. Multiple rows
1. tips:
UILabel class:
1-1-1). If you want to set a line spacing rich text with a ellipsis, you need to set it to be omitted again (the setting will expire during initialization ).
// End with "..." self. contentLabel. lineBreakMode = NSLineBreakByTruncatingTail;
UITextField class:
1-2-1.
// Self. inputTF. clearButtonMode = UITextFieldViewModeWhileEditing appears only when editing;
UITextView class:
1-3-1), UITextView can only be centered on the X axis, the Y axis needs to be manually adjusted
-- Modified from the simplified book "IOS UITextView content vertical center Method" -- wood Lee
-(Void) contentSizeToFit {// first, judge whether there is any text (there is no need to set the center if ([msgTextView. text length]> 0) {// The contentSize attribute of textView CGSize contentSize = msgTextView. contentSize; // the margin attribute UIEdgeInsets offset of textView; // if the text height does not exceed the height of textView, if (contentSize. height <= msgTextView. height) {// The height of textView minus the text height divided by 2 is the offset in the Y direction, that is, the top margin CGFloat offsetY = (msgTextView. height-contentSize. height)/2; offset = UIEdgeInsetsMake (offsetY, 0, 0, 0);} // according to the preceding calculation, set the ContentSize and Y offset of textView [msgTextView setContentInset: offset] ;}}
UITextField and UITextView have the following classes:
1-4-1). A ToolBar with the "finish" button on the right is displayed on the keyboard.
UIToolbar * numberToolBar = [[UIToolbar alloc] initWithFrame: CGRectMake (0, 0, kSCREEN_WIDTH, 40)]; numberToolBar. items = [NSArray arrayWithObjects: [[UIBarButtonItem alloc] failed: Invalid target: nil action: nil], [[UIBarButtonItem alloc] initWithTitle: @ "finished" style: Finished target: self action: @ selector (doneWithNumberPad)], nil]; // numberToolBar. tintColor = [UIColor redColor]; self. inputTF. inputAccessoryView = numberToolBar;-(void) doneWithNumberPad {}
1-4-2), Protocol UITextInputTraits (automatic upper case, error correction, keyboard-related ):
①. AutocapitalizationType: automatically capitalized
② AutocorrectionType: Automatic Error Correction
③ SpellCheckingType: spelling check
④ KeyboardType: keyboard type
⑤ KeyboardAppearance: keyboard Color Style
6. returnKeyType: the return button "word": Send, next...
7. enablesReturnKeyAutomatically: when the text input length is 0, the return of the failed keyboard, but the text input length is greater than 0, enable the return of the keyboard
Secret, secureTextEntry: enter the password, enter a period of time, or enter the next font, it will become *
Delimiter and textContentType: Convert the address book content into a ToolBar button on the keyboard and enter it quickly. Third-party keyboards do not seem to be supported.