M
M
Maxim2018-11-14 14:50:11
iOS
Maxim, 2018-11-14 14:50:11

How to display text in UILabel?

Hello!
The title of the question is slightly incorrect, now I will describe everything in more detail.
I have several buttons with text and Label. In the label, you need to display the text of these buttons, but at the same time so that these texts can be folded into one.
Example: button with text "1" and button with text "2" and so on. How to make that when you click on them, the text is added to the UILabel to display for example 21?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iMaximus, 2018-11-14
@Valter1234

Hey!
This is
easy let button1text: String = button1.titleLabel?.text ?? ""
let button2text: String = button2.titleLabel?.text ?? ""
label.text = "\(button1text)\(button2text)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question