18
Custom Controls

You have used several controls in the course of this book, including instances of UIButton, UITextField, and UISegmentedControl. These controls are subclasses of UIControl, and they allow you to respond to user interaction – generally using the target-action design pattern. Figure 18.1 shows some UIControl subclasses that you have used or may have seen.

Figure 18.1  UIControl subclasses

UIControl subclasses

We have discussed target-action pairs elsewhere in this book, including in the overview of common iOS design patterns at the end of Chapter 9. Recall that types that use the target-action pattern have a target (another instance to inform of some event that has occurred) and an action (some method to call on that target).

In this chapter, you are going to add a custom control to the Mandala application (Figure 18.2) that will indicate which mood is currently selected by displaying a colored circle beneath the emoji image. This custom control will replace the stack view of buttons currently at the bottom of the interface and will use the target-action pattern to inform the associated view controller of selection changes.

Figure 18.2  Completed ImageSelector

Completed ImageSelector
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.247