Graphics Programs Reference
In-Depth Information
isView in the middle of the screen. Also, the HypnosisView stretches 100 points to
the right and 150 points down due to its size .
Create another instance of HypnosisView in HypnosisterAppDelegate.m and
add it to the window in a different position and with a different size and background color.
[[self window] addSubview:view];
CGRect anotherFrame = CGRectMake(20, 30, 50, 50);
HypnosisView *anotherView = [[HypnosisView alloc] initWithFrame:anotherFrame];
[anotherView setBackgroundColor:[UIColor blueColor]];
[[self window] addSubview:anotherView];
self.window.backgroundColor = [UIColor whiteColor];
Build and run again. Notice that there are now two rectangles; these are the two instances
of HypnosisView . Figure 6.7 shows the view hierarchy.
Figure 6.7 View hierarchy with both HypnosisViews as subviews of the window
A view hierarchy can be deeper than two levels. In HypnosisterAppDelegate.m ,
insert anotherView as a subview of the first view instead of as a subview of the win-
dow.
 
Search WWH ::




Custom Search