2
votes

I'm working on an iPad game that's using SpriteKit. I need to be able to add a UIView atop the SKView that gets created by default. I am trying to do so like this in SKScene:

- (void)didMoveToView:(SKView *)view
{
    float currentTop = (self.view.frame.size.width - 100);
    float tileViewWidth = self.view.frame.size.height;
    CGRect tileViewRect = CGRectMake(0, currentTop, tileViewWidth, 100);
    self.fTileView = [[UIView alloc] initWithFrame:tileViewRect];
    [view addSubview:self.fTileView];
}

But the view never shows up, I just get the default SKView. Why is this?

1
how you can solve this ? i have face same issue @user1115716Anil Prasad
See the answer, that was what worked for me.easythrees
thanks for your replay @user1115716Anil Prasad

1 Answers

2
votes

The view does get added, but you cannot see it as the background color is transparent.

Edit your code like so:

self.fTileView = [[UIView alloc] initWithFrame:tileViewRect];
self.fTileView.backgroundColor = [UIColor whiteColor];
[view addSubview:self.fTileView];

And you will see the view at the bottom of the screen.