[UIKit] TextView

Enzo61
2 min readMar 9, 2022

--

When a user taps a text view, a keyboard appears;

when a user taps Return in the keyboard, the keyboard disappears and the text view can handle the input in an application-specific way.

You can specify attributes, such as font, color, and alignment, that apply to all text in a text view.

基礎設定:

Editable — 可對TextView裡的文字進行edit

Selectable — 可Select TextView裡的文字

Data Detectors — 自動辨認TextView裡的文字,如有match的可變成連結,需要Selectable On,Editable Off才能生效

實驗:
- 網址成功
- 美國地址成功,香港英文地址成功,香港中文地址失敗 (據說調整手機地區設定可能會成功)
- 美國和香港航空公司的航班都失敗
- 電話號碼支持格式如圖

Keyboard:
Do not dismiss — 鍵盤不會dismiss
Dismiss on drag — 鍵盤drag的時候會dismiss
Dismiss interactively —暫時測到和on drag一樣,沒測出什麼區別

另外的Text三連星系列:

Text三連星的區別:

  • UILabel defines a label, which displays a static text string.
  • UITextField defines a text field, which displays a single line of editable text.
  • UITextView defines a text view, which displays multiple lines of editable text.

--

--