'Xcode program: Text box that the user can interact with through touch

I am new to Xcode and Swift.

I want to create a text box for a video game that acts as the dialogue between the game and the user. for example I want the text box to say (character name) walked 10 paces or "Used 'detect evil' orc within 60'. "

I also want the ability for the user to pressure touch this chat text message which is sent from the computer and then do a series of actions. For example if a paladin detects evil maybe the next course of action would be to hide or prepare to fight. Any ideas on how to set this up? I have been trying to create this on Main.storyboard. Can I only achieve this through the ViewController or one of the delegates?



Solution 1:[1]

First of all, you can only achieve this by coding (by using Storyboards as your ally of course!)

If you want to have a text box that is "clickable", what first comes to mind is just a button, that have no background color, so it looks just like text.

Then you need to create a method inside of your ViewController, ideally something like:

@IBAction func dialogBoxTapped(_ sender: Any?) {
// your code goes here
}

And connect your button to this function by setting up a touchUpInside method in the Storyboard.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ferus