Information Technology Reference
In-Depth Information
You see two new files: IBView.m and IBView.h . IBView.m includes a sparse selection of extra code that
provides a minimal starting point for further customization. It also includes a method called drawRect: ,
which draws custom graphics in the view. By default, this method is commented out. Before we add code to it,
we need to take a closer look at the iOS UI.
Figure 8.5 shows the dimensions of the background view as they appear in the Size Inspector. At the top right,
you can see that the view is 320x460 pixels. The iPhone screen is 320x480 pixels. Why are 20 pixels missing?
In fact, the default view allows for the status bar at the top of the UI, which is exactly 20 pixels high. The y co-
ordinate of the view is offset by 20, and the view is 20 pixels smaller to compensate.
When you use a background view of any kind in an iOS UI, you must adjust the dimensions to allow for other
visible objects. This can affect the calculations used to create custom graphics.
In this example, the view's internal top-left coordinates remain at 0,0. The bottom-right coordinates are adjus-
ted to 320,460 to allow for the smaller view size.
If the UI included other items such as a navigation bar, toolbar, or tab bar, the view's dimensions and coordin-
ates would have to be changed accordingly.
FIGURE 8.5
Checking the size of the view with the Size Inspector
Search WWH ::




Custom Search