SpriteKit的屏幕大小模式有如下四种:
@availability(iOS, introduced=7.0)
enum SKSceneScaleMode : Int {
case Fill /* Scale the SKScene to fill the entire SKView. */
case AspectFill /* Scale the SKScene to fill the SKView while preserving the scene's aspect ratio. Some cropping may occur if the view has a different aspect ratio. */
case AspectFit /* Scale the SKScene to fit within the SKView while preserving the scene's aspect ratio. Some letterboxing may occur if the view has a different aspect ratio. */
case ResizeFill /* Modify the SKScene's actual size to exactly match the SKView. */
}
下面逐一进行解释,为了方便解释,我们不妨将原始屏幕的大小设置为1536*1536(正方形),并设置同样大小的背景图片居中显示,然后观察其显示效果:
原始图片的效果: