The text view (Uitextview) is similar to a text box (Uitextfield), except that the text view displays a scrollable and editable block of text for the user to read or modify. You should use Uitextview only if you need a lot of input.
Uitextview is a class that allows you to set various properties in the Attribute Inspector after the text box is selected.
Attribute Inspector is divided into 3 parts, namely TextField, control and view. Let's focus on the TextField section, the TextField section has the following options:
- Text: Sets the default text for the text box.
- Text color: Sets the colors in text boxes.
- Font: Sets the font and size of the text.
- Next, there are 5 buttons to set the alignment.
- Placeholder: You can display gray words in a text box to indicate what the user should enter in the text box. When this text box enters the data, the gray word for the hint will automatically disappear.
- Background: Sets the background.
- Disabled: Sets the background of the TextField when enable is No.
- Border style: Select a border style.
- Clear button: This is a drop-down menu, you can choose to clear when the button appears, the so-called Clear button is a text box to the right of the small x, you can choose:
(1) Never appears: never appear;
(2) appears while editing: appears when editing;
(3) appears unless editing: do not appear when editing;
(4) is always visible: appears.
- Clear when editing begins: If this is selected, the previous contents of the text box will be erased when you start editing the text box. For example, now that the text box A is entered "what", then to edit the text box B, if you come back to edit the text box A, then the "what" will be immediately cleared.
- Min Font Size: Sets the minimum font that the text box can display.
- Adjust to Fit: Specifies whether the text in the text box also shrinks when the text box size decreases. Select it to make all text visible and timely text to be long. However, this option is used with the Min font size, and the text shrinks, not less than the set min font size.
The next sections are used to set how the keyboard is displayed.
-
Captitalization: Sets uppercase. There are four options in the drop-down menu.
(1) None: do not set uppercase;
(2) Words: Capitalize the first letter of each word, where the word refers to a string separated by a space.
(3) Sentances: The first letter of each sentence is capitalized, and the sentence here is a string separated by a period plus a space.
(4) All characters: capitalization of all letters.
-
Correction: Check spelling, default is yes.
- Keyboard: Select the keyboard type, such as full numbers, letters, and numbers.
- Return key: Select the return key to select Search, return, done, and so on.
- Auto-enable Return key: If selected, the keyboard's return key is valid only if at least one character is entered in the text box.
- Secure text Entry: When your text box is used as a password input box, you can select this option, at which point the character is displayed as an asterisk
Control Section:
1.Alignment Horizontal Horizontal alignment
2.Alignment Vertical Vertical Alignment
3. Returns a bool value if the input box is Selected (checked) Enabled (editable) highlighted (highlighted)
The above are the basic properties of Uitextfield and Uitextview, mainly in the attribute inspector in storyboard implementation, but also through the code implementation, of course, for beginners, can be directly selected, but it is best to use the full code implementation later.
IOS Uitextfield and Uitextview