zoukankan      html  css  js  c++  java
  • SDWebImage播放GIF图

    播放GIF图有好几种方法

    1.可以直接用ImageView一帧一帧的播放

    2.可以用WebView加载一个页面播放

    .

    .

    .

    但是它们的缺点比较明显,会失帧,如果图比较大多话,还有可能在屏幕比较小的设备上不能完全显示出来,

    SDWebImage提供了很好的方法,只要导入播放GIF的头文件,只需短短的几行代码就可以实现。示例代码如下:

    #import "ViewController.h"
    #import "UIImage+GIF.h"
    @interface ViewController ()
    @property (nonatomic,strong) UIImageView *loadingImageView;
    @end

    @implementation ViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
        [self initLoadingImageView];
    }

    - (void)initLoadingImageView
    {
     
        NSString  *name = @"4升级.gif";
        NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];
        NSData  *imageData = [NSData dataWithContentsOfFile:filePath];
        
      if (!self.loadingImageView) {    
            self.loadingImageView = [[UIImageView alloc]init];
        }
        self.loadingImageView.backgroundColor = [UIColor clearColor];
        
        self.loadingImageView.image = [UIImage sd_animatedGIFWithData:imageData];
        self.loadingImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        
        [self.view addSubview:self.loadingImageView];
        
        [self.view bringSubviewToFront:self.loadingImageView];
        
    }
    @end

  • 相关阅读:
    26 Oracle数据库——分页
    25 PLSQL图形化操作
    24 数据库练习——简单练习
    23 SQL语言——视图 VIEW
    22 SQL语言——索引 index
    21 SQL语言——序列
    20 表结构的增删改
    19 Oracle外键约束
    18 SQL语言——约束
    17 SQL语言——子查询与关键字in
  • 原文地址:https://www.cnblogs.com/MJP334414/p/4953922.html
Copyright © 2011-2022 走看看