CATiledLayer 高于正常 CALayer

发布于 2024-10-17 22:42:53 字数 828 浏览 1 评论 0原文

我正在尝试在一个图层上添加两个子图层。一个图层应充当(快速渲染)背景,而另一图层(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 上方可见?提前致谢。

I am trying to add two sublayers on a layer. One layer should act as a (fast rendering) background while the other (the CATiledLayer) should display other content. However, the CATiledLayer won't appear at front. The normal CALayer always hides the CATiledLayer. When I remove the line

[self.layer addSublayer:lowRes];

the CATiledLayer is visible. But the background is not off course.

Here is the relevant code part

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];

How can i make the CATiledLayer visible above the CALayer? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俯瞰星空 2024-10-24 22:42:53

已经尝试反转 addSubLayer 调用?

[self.layer addSublayer:lowRes];

[self.layer addSublayer:tiledLayer];    

already tried to invert the addSubLayer calls?

[self.layer addSublayer:lowRes];

[self.layer addSublayer:tiledLayer];    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文