使用Xcode 10构建时在iOS10上的像素化​​图像 [英] Pixelated images on iOS10 when building with Xcode 10

查看:63
本文介绍了使用Xcode 10构建时在iOS10上的像素化​​图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的测试,我仅在进行存档并将其上传到Fabric或iTunesConnect时遇到此问题.在模拟器中和在调试中的真实设备上都可以.我尝试了pdf和png.我尝试更改资产目录中的压缩类型.

According to my test I only face this issue when making Archive and uploading it to Fabric or iTunesConnect. It's OK in simulator and on real device in debug. I tried both pdf and png. And I tried to change compression type in assets catalog.

归档在左侧,调试在右侧

Archive on the left, Debug on the right

推荐答案

用于创建ButtonBarItem图片的说明

  • 创建尺寸为22 x 22的PDF文件
  • 使用矢量工具绘制内容(请勿将图像嵌入PDF)
  • 使用1pt或1.5pt的笔划宽度
  • 拖动&将PDF拖放到Assets.xcassets
  • 有三个比例尺的插槽,选择1x的左侧
  • 否则请不要更改默认设置

在构建时,XCode以1x,2x和3x比例创建正确的图像.

At build time XCode creates the correct images in 1x, 2x and 3x scale.

如果这不能产生理想的结果,您将在此处找到有关如何进一步挖掘的提示.

If this does not produce the desired result, you will find here some hints on how to dig further.

调试版本和最终版本之间有什么区别

当您提交到应用商店时,将启动一个名为应用细化"的过程,该过程将为不同的实际设备创建变体.然后还会发生诸如图像压缩之类的事情.

When you submit to the app store a process called App Thinning is started that creates variants for different actual devices. Also stuff like image compression happens then.

等待构建App Store版本是不方便的,但是您也可以在本地执行App Thinning并分析确切创建的映像版本.但是其中涉及一些手动步骤.

It is inconvenient to wait for a build of the App Store version, but you can also perform App Thinning locally and analyze the exact created image version. But there are some manual steps involved.

我们正在寻找的是.png文件,该文件是从箭头PDF文件中创建的.由于将多个图像压缩并组合成一个.car文件,因此我们还需要一个工具来从该文件中提取图像.可以使用GitHub上提供的名为"Asset Catalog Tinkerer"的应用程序-但也可以使用软件包管理器Homebrew进行安装,请参见 https://brew.sh .下面有更多详细信息.

What we are looking for is the .png file that is created out of the arrow PDF file. Since multiple images are compressed and combined into a .car file we need also a tool to extract the images from that file. One could use an application called 'Asset Catalog Tinkerer' available from GitHub - but it can also installed using the package manager Homebrew, see https://brew.sh. More details below.

如何在本地进行应用程序稀疏

  • 在Xcode中选择< Product/Archive>
  • 打开< Window/Organizer>
  • 对于创建的存档,选择右侧的"Distribute App"
  • 从工作表中选择临时"
  • 从应用程序精简"组合中选择您的型号或所有兼容的设备变体"
  • 在下一个对话框中,选择自动管理签名"
  • 然后需要一些时间
  • 然后选择导出"并保存

提取Asset.car

  • 在输出文件夹中,现在有一个文件"App Thinning Size Report.txt"在文本编辑器中打开
  • 列出了所有针对不同设备生成的变体
  • 例如如果您在iOS 10上使用5s,它将列为 [设备:iPhone6,2,操作系统版本:10]
  • 相应的.ipa文件只是一个zip文件,请从命令行将其解压缩('unzip xxx.ipa')
  • 在提取的有效载荷"文件夹中有该应用程序,在Finder中右键单击该应用程序,然后选择显示包装内容"
  • 有一个名为"Asset.car"的文件,其中包含以最终格式创建的图像

从Asset.car提取图像

    通过在命令行上使用homebrew
  • 安装资产目录修补匠: brew cask install asset-catalog-tinkerer
  • 从常规Applications目录中启动资产目录修补匠
  • 使用< File/Open>打开"Asset.car"
  • 选择导出所有图像..."
  • 然后您可以在图像编辑器中查看最终图像
  • install Asset Catalog Tinkerer by using homebrew on the command line: brew cask install asset-catalog-tinkerer
  • Start Asset Catalog Tinkerer from the normal Applications directory
  • use <File/Open> to open the 'Asset.car'
  • choose 'Export All Images...'
  • then you can take a look at the final image in an image editor

它的名称应为"XXX-ABC-ZZZ-Normal@2x.png",并且分辨率应为44x44,因为它的缩放比例为2x.

It should have a name like 'XXX-ABC-ZZZ-Normal@2x.png' and should have a resolution of 44x44, since it has 2x-scale.

更多信息:

观看此WWDC 2018视频:第227节,优化应用程序资产,https://developer.apple.com/videos/play/wwdc2018/227/

Take a look at this WWDC 2018 video: Session 227, Optimizing App Assets, https://developer.apple.com/videos/play/wwdc2018/227/

这篇关于使用Xcode 10构建时在iOS10上的像素化​​图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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