如何使用用户键入消息更改 UILabel 文本
How to change UILabel text with user typing message
是否可以通过用户交互更改 UILabel 文本?或者是否需要使用 UITextField 元素来完成?
能告诉我怎么做吗?
我认为不可能通过用户交互更改 UILabel 文本。
我会使用没有边框的 UITextField 使其看起来像 UILabel。您可以使用情节提要中的属性检查器来执行此操作。
UILabel
本质上是不可编辑的,来自 class reference:
The UILabel class implements a read-only text view.
您必须使用 UITextField
或 UITextView
- UITextView
比 UITextField
更像 UILabel
。
The UITextView class implements the behavior for a scrollable, multiline text region. The class supports the display of text using custom style information and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document.
是否可以通过用户交互更改 UILabel 文本?或者是否需要使用 UITextField 元素来完成?
能告诉我怎么做吗?
我认为不可能通过用户交互更改 UILabel 文本。
我会使用没有边框的 UITextField 使其看起来像 UILabel。您可以使用情节提要中的属性检查器来执行此操作。
UILabel
本质上是不可编辑的,来自 class reference:
The UILabel class implements a read-only text view.
您必须使用 UITextField
或 UITextView
- UITextView
比 UITextField
更像 UILabel
。
The UITextView class implements the behavior for a scrollable, multiline text region. The class supports the display of text using custom style information and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document.