Graphics Programs Reference
In-Depth Information
HypnosisView *anotherView = [[HypnosisView alloc] initWithFrame:anotherFrame];
[anotherView setBackgroundColor:[UIColor blueColor]];
[[self window] addSubview:anotherView];
[view addSubview:anotherView];
Build and run the application. Notice that even though
anotherView
's
frame
did not
change, its position on the screen did. A view's
frame
is relative to its superview, not the
window, so the top-left corner of
anotherView
is now inset
(20, 30)
points from
Figure 6.8 View hierarchy with one HypnosisView as a subview of the other