Creating a custom UIStackView 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 Add New Journal Entry screen that you saw in the app tour:
Figure 19.1: Add New Journal Entry screen showing the star rating
You can see a group of five stars just above the Get Location switch. Currently, the New Entry Scene and the Entry Detail Scene in the Main
storyboard file have placeholder view objects where the stars should be. You will create the RatingView
class, a custom subclass of the UIStackView
class, which you will use in both scenes. An instance of this class will display ratings as stars.
For the rest of this chapter, an instance...