views:

170

answers:

0

Hi,

I create NSViewController. It manage my view hierarchy and set other views in one NSBox.

- (void)displayViewController:(ManagingViewController *)vc
{
NSWindow *w = [box window];
NSView *v = [vc view];
[box setContentView:v];
}

I have two alternate views. The views have Quartz Composer root layer and CALayer sublayer.

 // ----------
 // Root Layer
 // ----------
 QCCompositionLayer* rootLayer = [QCCompositionLayer compositionLayerWithFile:[[NSBundle mainBundle]
                  pathForResource:@"BackgroundHome" 
                  ofType:@"qtz"]];
[self setLayer:rootLayer];
[self setWantsLayer:YES];


 // ----------
 // Menu Layer
 // ----------
 menusLayer = [CALayer layer];
 menusLayer.frame = rootLayer.bounds;
 menusLayer.layoutManager =[CAConstraintLayoutManager layoutManager];

 [rootLayer addSublayer:menusLayer];


 // --------------
 // Menu Items
 // --------------
 NSInteger i;
 for (i=0;i<[section count];i++) {
 NSString *name = [section objectAtIndex:i];

 CATextLayer *menuItemLayer = [CATextLayer layer];

 menuItemLayer.string = name;
 menuItemLayer.font = @"Lucida-Grande";
 menuItemLayer.fontSize = fontSize;
 menuItemLayer.foregroundColor = CGColorCreateGenericRGB(1.0,1.0,1.0,1.0);

 [menuItemLayer addConstraint:[CAConstraint
       constraintWithAttribute:kCAConstraintMaxY
       relativeTo:@"superlayer"
       attribute:kCAConstraintMaxY
       offset:-(i*height+spacing+initialOffset)]];
 [menuItemLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMidX
            relativeTo:@"superlayer"
             attribute:kCAConstraintMidX]];

 [menusLayer addSublayer:menuItemLayer];
 }
 [menusLayer layoutIfNeeded];

I run my application, I can alternate views but I only look the QCCompositionLayer. When I use my custom NSView class directly, without NSView hierarchy, I can look all. Where's the error?

Excuse my bad english and thanks