使 SKScene 的背景透明不起作用......这是一个错误吗? [英] Making a SKScene's background transparent not working... is this a bug?

查看:26
本文介绍了使 SKScene 的背景透明不起作用......这是一个错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让 SKScene 的背景透明,并将该场景呈现在另一个通过透明度看到的场景上.

Is there a way to make a SKScene's background transparent and present that scene over another one seeing thru the transparency.

这个想法是让呈现场景的背景像这样:

The idea is to have the background of the presented scene like this:

self.backgroundColor = [SKColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f];

什么可以让看到背后的场景变暗.但这样做是行不通的.背景呈现完全不透明.

what would allow to see the scene behind darken. But doing this is not working. Background is presented completely opaque.

有没有办法做到这一点?

Is there a way to do that?

推荐答案

在 iOS 8 中,可以设置场景的 SKView 允许透明,设置场景的背景色具有透明.然后将看到 SKView 后面的视图.

In iOS 8, you can set the scene's SKView to allow transparency and set the scene's background color to have transparency. Then views behind the SKView will be seen.

UIView *parentView = ...;
[parentView addSubview:backgroundView];
[parentView addSubview:skViewWithScene];
skViewWithScene.allowsTransparency = YES;
scene.backgroundColor = [UIColor clearColor];
[skViewWithScene presentScene:scene];

这篇关于使 SKScene 的背景透明不起作用......这是一个错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆