Does any one know how to add GIF image files to an Asset Catalog in XCode5?
How to add GIF images to Asset Catalog in XCode5
Asked Answered
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 @Joey, I could not get this to work in modern Xcode (7.2.1). The
.xcassets
editor displays the manually-created .imageset
correctly, but calling imageNamed:
on it returns nil
. –
Endocranium 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. –
Geibel
@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... –
Maclean © 2022 - 2024 — McMap. All rights reserved.
iOS
SDK. – Golden