In this chapter, we are going to use both AppKit and direct Core Graphics code to create custom views. Two of those views will be clock faces, which will give us ample opportunities to explore the most common drawing methods. The other view will be a fairly straightforward custom button.
We are not actually designing an app, so much as designing subclasses of NSView
that can be added to any app we wish. We are designing views outside of an actual app project.
This is a good way to ensure that your code is well encapsulated, as well as helping us to focus on the task at hand, rather than being distracted by the rest of an app's implementation.
So, each of these views will hold all the methods and properties needed to draw itself, without needing to refer to the environment in which it is created. When we initiate one of these views, we will only need to supply the frame in which it is to be drawn, much as we would do with any other view.