SKSpriteNode using PDF/SVG Vector Image for automatic scaling

醉酒当歌 提交于 2020-01-16 12:18:06

问题


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.



来源:https://stackoverflow.com/questions/50078362/skspritenode-using-pdf-svg-vector-image-for-automatic-scaling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!