zoukankan      html  css  js  c++  java
  • iOS_UIImge_Gif的展示

    github地址: https://github.com/mancongiOS/UIImage.git

    方式一: 用动画展示

        UIImageView *gifImageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        gifImageView.backgroundColor = [UIColor orangeColor];
        NSArray *gifArray = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"1.png"],
                             [UIImage imageNamed:@"2.png"],
                             [UIImage imageNamed:@"3.png"],
                             [UIImage imageNamed:@"4.png"],
                             [UIImage imageNamed:@"5.png"],
                             [UIImage imageNamed:@"6.png"],
                             [UIImage imageNamed:@"7.png"],
                             [UIImage imageNamed:@"8.png"],
                             
                             nil];
        gifImageView.animationImages = gifArray; //动画图片数组
        gifImageView.animationDuration = 5; //执行一次完整动画所需的时长
        gifImageView.animationRepeatCount = MAXFLOAT;  //动画重复次数
        [gifImageView startAnimating];
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            
            // [gifImageView stopAnimating];
        });
        
        [self.view addSubview:gifImageView];

    方式二:用UIWebView展示

        UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -44, self.view.bounds.size.width, self.view.bounds.size.height + 44)];
        webView.userInteractionEnabled = NO;
        webView.backgroundColor = [UIColor redColor];
        
        NSString *path = [[NSBundle mainBundle] bundlePath];
        NSURL *baseURL = [NSURL fileURLWithPath:path];
        NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"index"
                                                              ofType:@"html"];
        NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
                                                        encoding:NSUTF8StringEncoding
                                                           error:nil];
        [webView loadHTMLString:htmlCont baseURL:baseURL];
        
        
        [self.view addSubview:webView];

    其中的HTML文件

    <!DOCTYPE html>
    <html>
    <head>
    </head>
    
    <body>
    <IMG src="gif.gif" border=0 width="100%" height="100%">
    </body>
    
    </html>
  • 相关阅读:
    QQ机器人
    Javascript实现base64的加密解密
    C# 对List<T>取交集、连集及差集
    简单正则验证
    中止线程
    线程同步synchronized
    volatile
    并发
    垃圾回收机制
    给定一个正整数num ,反复将各个位上的数字相加,直到结果为一位数
  • 原文地址:https://www.cnblogs.com/mancong/p/6138157.html
Copyright © 2011-2022 走看看