Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add GIF images to Asset Catalog in XCode5

Does any one know how to add GIF image files to an Asset Catalog in XCode5?

like image 557
carbonr Avatar asked Oct 19 '13 05:10

carbonr


People also ask

How do I add an asset catalog in Xcode?

If you don't already have an asset catalog in your project, you can create one by right-click on your project and choosing New File. From "iOS" choose "Resource" then Asset Catalog, then click Next and name your catalog. You can now select your new asset catalog in Xcode, and drag pictures directly into it.


1 Answers

Go to your Images.xcassets folder and create a folder named MyGifAnimation.xcassets, then put your [email protected] and MyGifAnimation.gif files in it. After that, create a Contents.json file. Open that with your favorite text editor and write the following in it:

{
    "images": [{
        "idiom": "universal",
        "scale": "1x",
        "filename": "MyGifAnimation.gif"
    }, {
        "idiom": "universal",
        "scale": "2x",
        "filename": "[email protected]"
    }],
    "info": {
        "version": 1,
        "author": "xcode"
    }
}

You'll have to handle the animation yourself as loading it directly to a UIImageView won't result in an animated gif.

like image 198
isair Avatar answered Nov 13 '22 16:11

isair