Does any one know how to add GIF image files to an Asset Catalog in XCode5?
1 Answer
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.
-
2Like @Joey, I could not get this to work in modern Xcode (7.2.1). The
.xcassets
editor displays the manually-created.imageset
correctly, but callingimageNamed:
on it returnsnil
. Commented Feb 15, 2016 at 17:34 -
Thanks for letting me know guys, I'll check this issue and update my answer soon. This is a hacky way so I can understand it not working anymore.– isairCommented Feb 17, 2016 at 1:39
-
@BarışŞencan It doesn't look that hacky; can't check right now the exact details but it looks pretty much like the
Contents.json
files that Xcode typically generates... Commented Feb 17, 2016 at 1:47
iOS
SDK.