SKColor clearColor returning a black color instead

2019-01-25 08:52发布

问题:

I have setup my SKScene the following way during initiation:

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {


        self.backgroundColor = [SKColor clearColor];

    }
    return self;
}

But somehow, what I am given is the following, which is black, not clear at all:

What am I missing here? How can I make this scene clear? I have already made the view holding the scene clear yet this is still what I get.

Update: I have also tried setting myView.opaque = NO; but this did not help at all.

回答1:

Setting it to clear is working correct, resulting in no colour, so black.

Set to any colour you like via

self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];


回答2:

iOS 8 supports transparency:

skView.allowsTransparency = YES;


回答3:

After try many things, this worked for me

skView.allowsTransparency = true
skView.backgroundColor = UIColor.clear
view.addSubview(skView)
floatingCollectionScene = BubblesScene(size: skView.bounds.size)
floatingCollectionScene.backgroundColor = UIColor.clear
floatingCollectionScene.scaleMode = .resizeFill
skView.presentScene(floatingCollectionScene)