In this recipe, we will take a look at
how we use buttons to change the contents of a UILabel
control that we defined in the previous recipe.
In this recipe, we will start by creating a
UIButton
object that will be used to modify the background color of a label when it is tapped.
In order to see how this can be achieved, we need to modify the ViewObjectsExample application that we created in the previous recipe. Perform the following steps to do so:
Open the
ViewObjectsExample.xcodeproj
project file.Select the
ViewController.xib
file from the project navigator window.From Object Library, drag a Round Rect Button object onto the subview and place it underneath the label we added previously.
From the Attributes Inspector section, modify the Title property to read Tap Here.
Next, create the outlet and properties for this Round Rect Button object, and name it
btnTapHere
.Next, create the action method for the Tap Here button...