user3149877
user3149877

Reputation: 155

How to change UILabel text with user typing message

Is it possible to change the UILabel text by user interaction? Or is it necessary to do it with a UITextField element?

Can you tell me the way of doing it?

Upvotes: 1

Views: 124

Answers (2)

Wyetro
Wyetro

Reputation: 8588

UILabel is inherently not editable, from the class reference:

The UILabel class implements a read-only text view.

You would have to use a UITextField or a UITextView - UITextView being more like a UILabel than a UITextField.

From the UITextView class reference:

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.

Upvotes: 0

Albert Ghar
Albert Ghar

Reputation: 428

I don't think that it's possible to change the UILabel text by user interaction.

I would use a UITextField with no borders to make it look like a UILabel. You can do this using the Attributes Inspector in the storyboard.

enter image description here

Upvotes: 1

Related Questions