菜鸟教程小白 发表于 2022-12-12 10:58:58

ios - 如何在ios中加载gif图像并控制它?


                                            <p><p>在我的应用程序中,我想在我的 View 中加载 gif 图像并控制停止和继续动画。 <img src="/image/bt1bl.png" alt="when i click pause button application should stop animating and when again click start animating"/> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>请遵循以下可能对您有所帮助的教程。
<a href="http://anand3777.blogspot.in/2014/07/gif-image-loading.html" rel="noreferrer noopener nofollow">http://anand3777.blogspot.in/2014/07/gif-image-loading.html</a> </p>

<p>第 1 步:</p>

<pre><code>   Download library from below url and add it on your project.

https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&amp;usp=sharing
</code></pre>

<p>第 2 步:</p>

<pre><code>Import the file on your &#34;viewController.h&#34; like below.
//gifImage//
#import &#34;SCGIFImageView.h&#34;
//gifImage//
</code></pre>

<p>第 3 步:</p>

<pre><code>    Create object like given below on your &#34;viewController.h&#34;.
    //gifImage//
    IBOutlet SCGIFImageView* _gifImageView;
    IBOutlet UIButton* _button;
    //gifImage//
</code></pre>

<p>第 4 步:</p>

<pre><code>   Create ibaction on your &#34;viewController&#34;.
   //gifImage//
    - (IBAction)controlAnimate:(id)sender;
   //gifImage//
</code></pre>

<p>第 5 步:</p>

<pre><code>   Add the following code were you want to use gif image
//gifImage//
//load url gif image
NSURL *imageURL = ;
NSData *imageData = ;
/*
   //load local gif image
   NSString* filePath = [ pathForResource:@&#34;1.gif&#34; ofType:nil];
   NSData* imageData = ;
*/
_gifImageView = [ initWithFrame:CGRectMake(225, 70, 75, 75)] ;
;
;
//gifImage//
</code></pre>

<p>第 6 步:</p>

<pre><code>   Add the following code for stop/start animating
//gifImage//
- (IBAction)controlAnimate:(id)sender{
   _gifImageView.animating = !_gifImageView.animating;

   if (_gifImageView.animating) {
         ;
   } else {
         ;
   }
}
//gifImage//


: https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&amp;usp=sharing
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何在ios中加载gif图像并控制它?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/25080760/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/25080760/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何在ios中加载gif图像并控制它?