我试图在一个图层上添加两个子图层。一层应作为(快速渲染)背景,而另一层(CATiledLayer)应显示其他内容。但是,CATiledLayer不会出现在前面。普通的CALayer始终隐藏CATiledLayer。当我删除线

[self.layer addSublayer:lowRes];


CATiledLayer可见。但是背景并非没有道理。

这是相关的代码部分

tiledLayer = [CATiledLayer layer];
//tiledLayer.delegate = self;
tiledLayer.tileSize = CGSizeMake(800.0, 800.0);
tiledLayer.levelsOfDetail = 4;
tiledLayer.levelsOfDetailBias = 4;
tiledLayer.frame = pageRect;
tiledLayer.zPosition = 2;
[tiledLayer setNeedsLayout];
[tiledLayer retain];

CALayer * lowRes = [CALayer layer];
lowRes.frame = tiledLayer.frame;
lowRes.zPosition = 1;
lowRes.contents = (id) [UIImage imageNamed:@"krant.jpg"].CGImage;
[self.layer addSublayer:tiledLayer];
[self.layer addSublayer:lowRes];


如何使CATiledLayer在CALayer上方可见?提前致谢。

最佳答案

已经尝试反转addSubLayer调用?

[self.layer addSublayer:lowRes];

[self.layer addSublayer:tiledLayer];

10-06 13:10