简体   繁体   English

Xcode 选项卡栏和 SVG 图标

[英]Xcode tab bar and SVG icons

I was hoping I could use SVG icons on a tab bar.我希望我可以在标签栏上使用 SVG 图标。 I'm currently using Xcode 12 beta 3 and whilst it works with these images, the icons don't seem to rescale.我目前正在使用 Xcode 12 beta 3,虽然它适用于这些图像,但图标似乎没有重新缩放。

Is there a solution to this?有针对这个的解决方法吗?

A few observations:几点观察:

  • See the Creating Custom Symbol Images for Your App for suggestions on how to build symbol SVG assets.有关如何构建符号 SVG 资产的建议,请参阅为您的应用创建自定义符号图像

  • Historically in Xcode, we couldn't easily use SVG assets.从历史上看,在 Xcode 中,我们不能轻易使用 SVG 资产。 But we could convert them to PDFs, which we could then drag into our asset catalogs.但是我们可以将它们转换为 PDF,然后我们可以将其拖到我们的资产目录中。 When you use the asset in the app, it still ends up rasterizing it, which it saves you from having to create bitmaps of the three different sizes yourself.当您在应用程序中使用资产时,它仍然会对其进行光栅化,这样您就不必自己创建三种不同大小的位图。 If you need to make it scalable (eg, notably, for accessibility), check the “preserve vector data” option in the asset catalog.如果您需要使其可扩展(例如,特别是可访问性),请选中资产目录中的“保留矢量数据”选项。

  • In Xcode 12 (only beta right now), the importing of SVG assets has greatly improved.在 Xcode 12(目前仅测试版)中,SVG 资产的导入有了很大的改进。 It still appears to rasterize the asset when you go to use it, though, just like the old PDF approach.但是,当您使用 go 使用它时,它似乎仍然会栅格化资产,就像旧的 PDF 方法一样。 You need to make sure your SVG/PDF has an artboard of the appropriate size for the eventually rasterized images.您需要确保您的 SVG/PDF 具有适合最终光栅化图像大小的画板。

If you consider these various vector graphic solutions, make sure to test this on your target minimum OS before you go too far.如果您考虑这些不同的矢量图形解决方案,请确保在 go 之前在您的目标最低操作系统上进行测试。 I had app with vector/PDF assets and got some unexpected edge-case behaviors on old OS versions.我有带有矢量/PDF 资产的应用程序,并且在旧操作系统版本上出现了一些意外的边缘情况行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM