Overlaying a UIControl over a SKSpriteNode

I'm currently using Metal to create a game board with floating balloons; each balloon is a SKSpriteNode with an image of a balloon attached. The user touches and drags the balloon to a second balloon, merging the two. Exactly how they get merged is based on input from the user. I have a UISegmentedControl that pops up where the user selects one of four responses and the merge occurs. Currently, the UISegmentedControl pops up in the middle of the game board; however, I would like it to overlay on top of the first balloon instead.

I have tried this once the two balloons touch each other:

bubble1.physicsBody!.velocity = CGVector(dx: 0, dy: 0) // Stopping the balloon

requestView.frame.origin.x = bubble1.position.x
requestView.frame.origin.y = bubble1.position.y

Where requestView is a UIView (with the same dimensions of the balloon) with various subviews (including the UISegmentedControl) and bubble1 is the SKSpriteNode (balloon).

However, when I add the requestView as a subview of the game board, it does not overlay on top of the SKSpriteNode (bubble1). In fact, each time I try it, it doesn't even seem to appear in the same space relative to the location of the bubble1.

Any thoughts on what I might be doing wrong?

Thanks!

Accepted Reply

In the end, I simply "recreated" a UISegmentedControl by inserting SKLabelNode that had user interaction turned on for a tap. I created a SKNode, inserted four labels for the options and attached an action to tapping each label. I then had this SKNode hidden by default and made it visible only after a user controlled collision occurred.

So, in the end, it's functional, even if I needed a little more programming to make it happen than a true UISegmentedControl.

Replies

In the end, I simply "recreated" a UISegmentedControl by inserting SKLabelNode that had user interaction turned on for a tap. I created a SKNode, inserted four labels for the options and attached an action to tapping each label. I then had this SKNode hidden by default and made it visible only after a user controlled collision occurred.

So, in the end, it's functional, even if I needed a little more programming to make it happen than a true UISegmentedControl.