gpt4 book ai didi

objective-c - 在 iOS 中显示动画 GIF

转载 作者:IT老高 更新时间:2023-10-28 11:20:42 31 4
gpt4 key购买 nike

我注意到使用 iMessage,现在可以发送和显示动画 gif。这是否意味着 Apple 现在支持在应用程序中显示动画 GIF,或者仍然是将图像分割成帧然后按顺序显示它们的最简单方法?从 iOS 5.1 开始,显示动画 GIF 的最简单方法是什么?

谢谢!

最佳答案

如果您的目标是 iOS7 并且已经将图像分割成帧,您可以使用 animatedImageNamed:duration:

假设您正在为微调器设置动画。将所有框架复制到项目中,并将它们命名如下:

  • spinner-1.png
  • spinner-2.png
  • spinner-3.png

然后通过以下方式创建图像:

[UIImage animatedImageNamed:@"spinner-" duration:1.0f];

From the docs :

This method loads a series of files by appending a series of numbers to the base file name provided in the name parameter. For example, if the name parameter had ‘image’ as its contents, this method would attempt to load images from files with the names ‘image0’, ‘image1’ and so on all the way up to ‘image1024’. All images included in the animated image should share the same size and scale.

关于objective-c - 在 iOS 中显示动画 GIF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9744682/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com