Avoiding SKView Stretching During Layout Animations

My app has an

SKView
instance in a view hierarchy that needs to support layout changes at run time (device orientation changes, window bounds changes when multitasking, et cetera).
SKView
inherits the
contentMode
property from
UIView
, so you can choose the drawing behavior during these animations, but the closest option (
UIViewContentMode.center
) still clips part of the presented scene during the animation, while
UIViewContentMode.redraw
doesn't have any visible effect.


Can anyone offer a way of doing this with the current API? If it's not currently possible, I'll file a bug report.

Went ahead and filed as bug report 28228151.

Interested in a solution to this issue as well.

override func didMove(to view: SKView) {
    scaleMode = .resizeFill
    view.contentMode = .center // This is the closest working solution indeed. But not quite there yet.
}

The documentation of setNeedsDisplay() method says:

If your view is backed by a CAEAGLLayer object, this method has no effect.

A CAEAGLLayer is "a layer that supports drawing OpenGL content." SpriteKit probably used that, then moved to Metal, and the same limitation still applies. But this is only speculation.

Source:

Avoiding SKView Stretching During Layout Animations
 
 
Q