如何将GIF图像添加到XCode5中的资产目录 [英] How to add GIF images to Asset Catalog in XCode5

查看:197
本文介绍了如何将GIF图像添加到XCode5中的资产目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道如何将GIF图像文件添加到XCode5中的资产目录?

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

推荐答案

转到图像。 xcassets文件夹并创建一个名为MyGifAnimation.xcassets的文件夹,然后将MyGifAnimation@2x.gif和MyGifAnimation.gif文件放入其中。之后,创建一个Contents.json文件。用您喜欢的文本编辑器打开它并在其中写下以下内容:

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"
    }
}

你必须自己处理动画,因为将它直接加载到UIImageView不会产生动画gif。

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

这篇关于如何将GIF图像添加到XCode5中的资产目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆