Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a SpriteKit scene with transparent BG on top of a uikit view hierarchy?

I'd like to take advantage of the particle effects (and maybe some other stuff) in SpriteKit but my app is mainly rooted in UIKit. Does the SpriteKit framework allow you to create a scene with a transparent background that I can place on top of my UIKit view hierarchy?

like image 715
nickthedude Avatar asked Sep 25 '13 05:09

nickthedude


2 Answers

As of iOS 8, Apple has added this ability: see SKView.allowsTransparency.

https://developer.apple.com/documentation/spritekit/skview/1519697-allowstransparency

It defaults to false, yielding the black rectangle background you see; but set it to true, set its background color to .clear, and it composites over UIKit content just fine.

Further info: Removing Background of SKView - Particle Emitter - SpriteKit

like image 101
rgeorge Avatar answered Sep 28 '22 07:09

rgeorge


Short answer is no. You can add SKView (subclass of UIView) to your view hierarchy, and set its scene to your own SKScene. But SKView has a backgroundcolor property that cannot be clear (defaults to grey). It seems possible in OSX mavericks, so hopefully apple will add this possibility in iOS as well.

like image 28
amir Avatar answered Sep 28 '22 08:09

amir