How to add GIF images to Asset Catalog in XCode5

狂风中的少年 提交于 2020-01-11 08:29:07

问题


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


回答1:


Go to your Images.xcassets folder and create a folder named MyGifAnimation.xcassets, then put your MyGifAnimation@2x.gif 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": "MyGifAnimation@2x.gif"
    }],
    "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.



来源:https://stackoverflow.com/questions/19462747/how-to-add-gif-images-to-asset-catalog-in-xcode5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!