Creating Controls
The process of building a UIControl generally involves four distinct steps. As Recipe 2-5 demonstrates, you begin by subclassing UIControl to create a new custom class. In that class, you lay out the visual look of the control in your initialization. Next, you build methods to track and interpret touches, and you finish by generating events and visual feedback.
Nearly all controls offer value of some kind. For example, switches have isOn, sliders have a floating-point value, and text fields offer text. The kinds of values you provide with a custom control are arbitrary. They can be integers, floats, strings, or even (as in Recipe 2-5) colors.
In Recipe 2-5, the control layout is basically a colored rectangle. More complex controls ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access