Creating a custom UIControl subclass
You’ve only used Apple’s predefined UI elements so far, such as labels and buttons. All you had to do was click the Library button, search for the object you want, and drag it into the storyboard. However, there will be cases where the objects provided by Apple are either unsuitable or don’t exist. In such cases, you will need to build your own. Let’s review the Restaurant Detail screen that you saw in the app tour:
Figure 20.1: Restaurant Detail screen showing the star rating
You can see a group of five stars just above the Add Review button. Currently, the Restaurant Detail View Controller Scene in the RestaurantDetail
storyboard file and the Table View Controller Scene in the ReviewForm
storyboard file have blank view objects where the stars should be. You will create the RatingsView
class, a custom subclass of the UIControl
class that you will use in both scenes. The UIControl
class is a subclass of...