FS.O5
FS.O5

Reputation: 297

Adding GIF files to Xcode assets folder

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

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.

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?

Upvotes: 4

Views: 7231

Answers (1)

Mohammad Sadiq
Mohammad Sadiq

Reputation: 5241

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" : "[email protected]"
    },
    {
      "idiom" : "universal",
      "scale" : "2x",
      "filename" : "[email protected]"
    },
    {
      "idiom" : "universal",
      "scale" : "3x",
      "filename" : "[email protected]"
    }
  ],
  "info" : {
    "author" : "xcode",
    "version" : "1"
  }
}

Upvotes: 4

Related Questions