我有这段代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
CGRect screenFrame = [UIScreen mainScreen].bounds;
_controller = [[UIViewController alloc] init];
_controller.view = [[UIView alloc] initWithFrame:screenFrame];
SKView *skView = [[SKView alloc] initWithFrame:screenFrame];
skView.backgroundColor = [SKColor blueColor];
[_controller.view addSubview:skView];
self.window.rootViewController = _controller;
[self.window makeKeyAndVisible];
return YES;
}
但是我没有看到蓝屏,而是看到了灰色屏幕。
我做错了什么?
感谢。
答案 0 :(得分:1)
我认为您需要从SKView中展示SKScene才能看到颜色。在AppDelegate中这样做很奇怪,但也许不是吗?我从未见过那种东西放在那里。
我有这个,它工作正常。
self.window.backgroundColor = [UIColor whiteColor];
CGRect screenFrame = [UIScreen mainScreen].bounds;
UIViewController *_controller = [[UIViewController alloc] init];
_controller.view = [[UIView alloc] initWithFrame:screenFrame];
SKView *skView = [[SKView alloc] initWithFrame:screenFrame];
SKScene *currentScene = [[SKScene alloc]initWithSize:skView.bounds.size];
currentScene.backgroundColor = [SKColor blueColor];
[_controller.view addSubview:skView];
[skView presentScene:currentScene];
self.window.rootViewController = _controller;
[self.window makeKeyAndVisible];
return YES;