zoukankan      html  css  js  c++  java
  • 汤姆猫(。。。。)

    1:如何使用UIImageView播放动画

    2:从bundle中加载图片的两种方式

    3怎么样延迟执行某个方法

    项目的源码以及素材

    链接: http://pan.baidu.com/s/1hq4fWrE 密码: xqkw

    主要的修改有:使用switch case来进行点击事件的区分。

    核心代码是:

    -(void)actionWithFilename:(NSString *)name andImgCount:(NSInteger)count{

        NSMutableArray *imgArr = [NSMutableArray array];

        for (int i = 0; i<count; i++) {

             NSString *imgName = [NSString stringWithFormat:@"%@%02d.jpg",name,i];

            NSString *path = [[NSBundle mainBundle]pathForResource:imgName ofType:nil];

            UIImage *image = [UIImage imageWithContentsOfFile:path];//系统不缓存图片

    //        UIImage *image = [UIImage imageNamed:imgName];//如果使用这种方法来加载bundle中的图片的时候,系统会自动缓存这些图片

            

            [imgArr addObject:image];

        }

        

        self.backIV.animationImages = imgArr;//注意这里的数组里存放的是image而不是字符串

        [self.backIV setAnimationImages:imgArr];

        self.backIV.animationDuration = count * .1;

        self.backIV.animationRepeatCount = 1;

        [self.backIV startAnimating];

        CGFloat time = self.backIV.animationRepeatCount * self.backIV.animationDuration;

    //    延迟执行某个方法

    //    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    //        self.backIV.animationImages = nil;//清除动画需要的图片

    //    });

        

        //就是将nil赋值给了AnimationImages 即[self.backIV setAnimationImages:nil];

        [self.backIV performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:time];

    }

  • 相关阅读:
    我的ORM之八-- 事件
    JavaScript(四):函数
    JavaScript(三):数据类型转换
    CSS(九):设置盒子水平垂直居中
    CSS(八):定位属性
    CSS(三):引入样式和优先级
    Dapper:安装Dapper时报错
    HTML(四):行级标签和块级标签
    解决Linux里面未启用网卡的问题
    linq操作符:分区操作符
  • 原文地址:https://www.cnblogs.com/mudy/p/4831587.html
Copyright © 2011-2022 走看看