• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-12 10:58:58 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

在我的应用程序中,我想在我的 View 中加载 gif 图像并控制停止和继续动画。 when i click pause button application should stop animating and when again click start animating



Best Answer-推荐答案


请遵循以下可能对您有所帮助的教程。 http://anand3777.blogspot.in/2014/07/gif-image-loading.html

第 1 步:

   Download library from below url and add it on your project.

https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&usp=sharing

第 2 步:

  Import the file on your "viewController.h" like below.
  //gifImage//
  #import "SCGIFImageView.h"
 //gifImage//

第 3 步:

    Create object like given below on your "viewController.h".
    //gifImage//
    IBOutlet SCGIFImageView* _gifImageView;
    IBOutlet UIButton* _button;
    //gifImage//

第 4 步:

   Create ibaction on your "viewController".
   //gifImage//
    - (IBAction)controlAnimateid)sender;
   //gifImage//

第 5 步:

   Add the following code were you want to use gif image
  //gifImage//
  //load url gif image
  NSURL *imageURL = [NSURL URLWithString"http://google.co.in/anim.gif"];
  NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
  /*
   //load local gif image
   NSString* filePath = [[NSBundle mainBundle] pathForResource"1.gif" ofType:nil];
   NSData* imageData = [NSData dataWithContentsOfFile:filePath];
 */
  _gifImageView = [[SCGIFImageView alloc] initWithFrame:CGRectMake(225, 70, 75, 75)] ;
 [_gifImageView setData:imageData];
 [self.view addSubview:_gifImageView];
 //gifImage//

第 6 步:

   Add the following code for stop/start animating
  //gifImage//
  - (IBAction)controlAnimateid)sender{
     _gifImageView.animating = !_gifImageView.animating;

     if (_gifImageView.animating) {
         [_button setTitle"ause" forState:UIControlStateNormal];
     } else {
         [_button setTitle"Continue" forState:UIControlStateNormal];
     }
  }
 //gifImage//


[1]: https://drive.google.com/folderview?id=0B5JC34Lt79ctamtOVTV6SHhzOVU&usp=sharing

关于ios - 如何在ios中加载gif图像并控制它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25080760/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap