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>
  • 相关阅读:
    Chapter 2 JavaScript Basic
    第一感觉:依赖注入读书笔记之一(草稿版)
    JQuery IN ACTION读书笔记之一: JQuery选择器
    使用Razor
    非侵入式Ajax
    QT定制有标题的扁平化下拉框控件
    JavaScript之this,new,delete,call,apply
    实例解析C++虚表
    Python解析生成XML-ElementTree VS minidom
    从Python传递JSON到JavaScript
  • 原文地址:https://www.cnblogs.com/mancong/p/6138157.html
Copyright © 2011-2022 走看看