1

I have a SKScene which I am Using aspectFit scaleMode because I want use this scene across multiple devices. Is there any way to change the letterbox color to transparent?

This is the result of my code

field!.scaleMode = .aspectFit
field?.view?.contentMode = .scaleAspectFit 
field?.view?.backgroundColor = .clear
    field?.backgroundColor = .clear
    field?.view?.allowsTransparency = true
    fv.contentMode = .scaleAspectFit
    fv.superview?.backgroundColor = .clear
    fv.scene?.backgroundColor = .clear
    fv.allowsTransparency = true
    fv.backgroundColor = .clear
    fv.showsFPS = false
    fv.showsNodeCount = false
    fv.ignoresSiblingOrder = false
    fv.presentScene(field)

Field is the SKScene and fv is the SKView which presents the scene.

danTheMan
  • 11
  • 2
  • did you try `SpriteView(scene: scene, options: [.allowsTransparency])` in your SwiftUI? – Fault Feb 05 '22 at 19:11
  • I am using story board for this app. And yes I have set the allows transparency property to true for both the skview and the scene. The scene is just made up of the soccer field and the background of the view controller is the green squares. It appears that the allows transparency is working. This only happens when i use aspect fit, when I use any tithe scaleModesl I see the entire background but it becomes stretched on the smaller iPhone devices and the iPad – danTheMan Feb 07 '22 at 15:29

0 Answers0