insertSublayer atIndex将事物放在其他层之上

时间:2012-06-06 20:31:17

标签: objective-c view insert indexing layer

我正在使用ColorBGView并在其中调用方法来制作渐变。但是,如果我将两个附加到我的图层,它会覆盖我之后附加的所有其他内容,我不明白为什么。

        CAGradientLayer *bgLayer = [ColorBGView pinkSky1];
        bgLayer.frame = CGRectMake(0, 0, 1024, 768);
        [viewController.view.layer insertSublayer:bgLayer atIndex:0];

    //If I insert this sublayer (even at a lower index) 
    //it overlaps everything I attach afterward

        CAGradientLayer *bgLayer2 = [ColorBGView darkCave];
        bgLayer2.frame = CGRectMake(0, 0, 1024, 768);
        [viewController.view.layer insertSublayer:bgLayer2 atIndex:-10];    

        // add custom view

        parallaxView = [[ParallaxView alloc] init];
        parallaxView.frame = CGRectMake(0, 0, 1024, 768);
        [viewController.view insertSubview:parallaxView atIndex:1];

        [parallaxView release];

0 个答案:

没有答案