• 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>
  • 相关阅读:
    全面了解Cookie
    HTML5实现无刷新修改URL
    闭包的理解
    JS中的prototype、__proto__与constructor
    Array.prototype.slice.call()方法详解
    深入理解 Array.prototype.map()
    网页布局——Flex弹性框布局
    vue项目的各个文件作用
    node使用心得
    node连接Mysql报错ER_NOT_SUPPORTED_AUTH_MODE
  • 原文地址:https://www.cnblogs.com/mancong/p/6138157.html
Copyright © 2020-2023  润新知