SKSpriteNode 使用 PDF/SVG 矢量图像进行自动缩放 [英] SKSpriteNode using PDF/SVG Vector Image for automatic scaling

查看:22
本文介绍了SKSpriteNode 使用 PDF/SVG 矢量图像进行自动缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PDF/SVG 图像作为 SKSpriteNode 的 SKTexture.我知道这可以通过勾选保留矢量数据",将缩放设置为单一比例"并将 UIImageView 配置为

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

在 SKTexture 中使用 UIImage 时可以这样做吗?这将阻止创建@2x &@3x 图片.

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

谢谢

推荐答案

您不能对 SKTexture 使用矢量图像

SKTexture 没有矢量格式,它只是一个位图图像.

You cannot use vector images for an SKTexture

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

因此,当您将 PDF 矢量图像添加到资产目录,然后从中创建 SKTexture 时,您将获得一个位图图像(如果您选择了 PDFcode>Preserve Vector Format and Single scale)

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)

这个过程的好处在于您不需要创建 1x、2x 和 3x 大小的图像,因为 Xcode 会在构建时为您完成.但是生成的纹理仍然是位图格式.

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.

这篇关于SKSpriteNode 使用 PDF/SVG 矢量图像进行自动缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆