Parent Justification

Full Justification

In the justifications you've seen so far, the size of the view is always fixed. In some cases, you may want a view's size to vary depending on the size of its parent. In these instances, you use parentRelativeFull justification (in either the horizontal or vertical direction). We will only look at horizontal full justification, since vertical full justification works the same way, except that it uses the top and bottom coordinates.

When you use parentRelativeFull horizontal justification, the left field of the viewBounds specifies the offset from the left of the parent, while the right field specifies the offset from the right of the parent (see FIGURE 5.20). Thus, setting left and right both to 0 causes the view to be exactly as wide as its parent, while setting the left to 5 and the right to -5 causes the child to be five pixels less wide on each of its sides (see FIGURE 5.21).


Note:When using parentRelativeFull justification, viewBounds specifies insets or offsets--not widths. Using a positive number in the right viewBounds results in a child view that extends beyond its parent. Likewise, using a negative number in the left viewBounds makes the child extend beyond its parent.


FIGURE 5.20 : parentRelativeFull horizontal justification.


When you use parentRelativeFull vertical justification, the top field specifies the offset from the top of the parent, while the bottom field specifies the offset from the bottom of the parent. Negative values specify an offset up, while positive values specify an offset down. Setting top and bottom both to 0 causes the view to be exactly as tall as its parent.

FIGURE 5.21 : Examples of horizontal parentRelativeFull justification.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996