SKSpriteNode using PDF/SVG Vector Image for automa

2019-08-16 07:38发布

问题:

I'm trying to use a PDF/SVG Image as the SKTexture for an SKSpriteNode. I know that this can be done for a UIImageView by ticking "Preserve Vector Data", setting Scaled to "Single Scale" and configuring the UIImageView to

imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true

Is this possible to do when using the UIImage in an SKTexture? This would prevent the creation of @2x & @3x images.

Thanks

回答1:

You cannot use vector images for an SKTexture

A SKTexture doesn't have a vector format, it's simply a bitmap image.

So when you add a PDF vector image to your asset catalog and then you create a SKTexture out of it, you get a bitmap image (also if you selected Preserve Vector Format and Single scale)

The good part of this procedure is that you don't need to create the 1x, 2x and 3x sized images since Xcode will do it for you at build time. But the generated texture is still going to be in bitmap format.