将GIF文件添加到Xcode资产文件夹 [英] Adding GIF files to Xcode assets folder

查看:439
本文介绍了将GIF文件添加到Xcode资产文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序使用 SwiftyGif使用了一些GIF文件(将GIF支持添加到类).

I have an app that uses some GIF files using SwiftyGif (a 3rd party API that adds GIF support to the class).

问题是GIF大小应为30x30.我已将30x30文件添加到项目中,但需要@2x@3x文件.您可能知道,Xcode有一个Images.xcassets文件夹,其中包含@1x@2x@3x文件,并且它具有一种算法来选择适当的文件.

The problem is that the GIF size should be 30x30. I've added a 30x30 file to the project but I need the @2x and @3x files. As you may know, Xcode has a Images.xcassets folder that's contains @1x, @2x, @3x files and it has an algorithm the chooses the appropriate file.

我试图将GIF文件添加到此文件夹中,但是这是不可能的,那么如何对GIF文件使用@1x@2x@3x方法?

I've tried to add the GIF file to this folder but it's not possible, so how can I use the @1x, @2x and @3x method with a GIF file?

推荐答案

您必须手动添加扩展名为.imageset的文件夹. 右键单击Assets.xcassets文件夹,然后转到finder中的位置. 添加扩展名为.imageset的资产文件夹. 将1x,2x和3x文件拖放到该文件夹​​中.添加一个文件Contents.json,然后在该文件中添加文件名.

You have to manually add the folder with .imageset extension. Right click on Assets.xcassets folder and go to location in finder. Add the asset folder with .imageset extensionn. Drop the 1x, 2x and 3x files to that folder. Add one file Contents.json, and add the file names in that file.

{
  "images" : [
    {
      "idiom" : "universal",
      "scale" : "1x",
      "filename" : "yourfile@1x.gif"
    },
    {
      "idiom" : "universal",
      "scale" : "2x",
      "filename" : "yourfile@2x.gif"
    },
    {
      "idiom" : "universal",
      "scale" : "3x",
      "filename" : "yourfile@3x.gif"
    }
  ],
  "info" : {
    "author" : "xcode",
    "version" : "1"
  }
}

这篇关于将GIF文件添加到Xcode资产文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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