Post

Replies

Boosts

Views

Activity

How to display some text when a button is clicked in Swift UI?
I have a function that displays "correct" when the user puts in the right answer. func displayCorrectOrIncorrect() -> some View { Group { 		if correctAnswer == quiz.answer	{ 				VStack { 						Text("Correct") 				} 		} else { 				VStack { 						Text("Incorrect, correct answer is \(correctAnswer)") 				} 		} } } This is how I call it: Button(action: { 						self.displayCorrectOrIncorrect() 						self.updateUI() 				}) The text is not showing up. How can I fix this?
2
0
4.6k
Jun ’20