Method of displaying GIF pictures in IOS development

We know that GIF is composed of bursts of images, and the playback of each frame may not be equal. Observing the above two examples, we find that they do not often process the display of each frame in GIF. As a result, each frame in the whole GIF is played forward at a fixed speed. Obviously, this does not always meet the demand. So I wrote a tool class for parsing GIF, solved each frame picture, and played it according to the display time corresponding to each frame. The idea of the program is as follows: 1. First, use the cgimagesource in the imageio library to store the GIF file at home. 2. Obtain the total number of frames in the GIF file and the display time of each frame through cgimagesource. 3. Play GIF animation through cakeyframeanimation. Here's the code I wrote to parse and play GIF's tool class:

The code is short and easy, so I won't explain it one by one. The first c function is mainly used to parse GIF. The reason why I use C function is that I want to return multiple information, while Objective-C can only return one parameter, and Objective-C and c languages can be easily mixed for programming.

In addition, two methods of using uiimageview are introduced:

1. Play with uiwebview

2. Decompose GIF pictures into multiple PNG pictures and play them with uiimageview. The code is as follows:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>