How can I add UIView in **spriteKit**?

2019-05-31 06:09发布

问题:

I am developing a game project using SpriteKit framework, now my requirement is i want to add UIView

control in my spriteKit project but unable to do it.

UIView *myview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 280, 480)];
[myview setBackgroundColor:[UIColor redColor]];
[self.scene.view addSubview:myview];

Currently i am adding UIView to SKScene like this but it is not working . thanks

回答1:

 [UIView transitionFromView:self.view toView:myview duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve completion:^(BOOL finished) {
// What to do when its finished.
[self.scene.view addSubview:myview];

}];