UILabel UITextField UITextView

后端 未结 5 1969
天涯浪人
天涯浪人 2020-12-12 14:36

What\'s the fundamental difference between them?

Is a UITextField that\'s not editable is effectively a UILabel?

Are those essentia

相关标签:
5条回答
  • 2020-12-12 15:19

    In addition to the above answers, UITextView has selectable text. This means that you can copy it or get the device to speak the text.

    0 讨论(0)
  • 2020-12-12 15:22
    • UILabel: "The UILabel class implements a read-only text view."
    • UITextField: "A UITextField object is a control that displays editable text and sends an action message to a target object when the user presses the return button."
    • UITextView: "The UITextView class implements the behavior for a scrollable, multiline text region."

    So:

    • labels are read-only
    • textfields are editable, and provide horizontal character seeking (not really scrolling) when the text is too long to display all at once. Generally used to input short text.
    • textviews are also editable, but provide vertical scrolling when the text is too long to display all at one.
    0 讨论(0)
  • 2020-12-12 15:26

    Also in addition to this: Only with UILabel you can get the Auto shrink feature, otherwise you should implement that (if needed)

    0 讨论(0)
  • 2020-12-12 15:32
    • UILabel - used for static text rendering,
    • UITextField - is an input field,
    • UITextView - is a multiline input field
    0 讨论(0)
  • 2020-12-12 15:34

    Finally Apple have covered this part in this amazing talk:

    https://developer.apple.com/videos/play/wwdc2018/221/

    The key takeways is as followed:

    0 讨论(0)
提交回复
热议问题