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];

    }

  • 相关阅读:
    如何恢复包含损坏记录的物理文件
    启动日志
    如何在各种环境中处理多成员的物理文件
    如何找出物理文件中损坏的记录
    如何重新找回物理文件中已经被删除的记录
    folder的操作
    如何将AS/400英文界面改为中文界面?
    如何从OS/400里直接发送电子邮件到Internet
    如何在AS/400上发送带有颜色的MESSAGE
    关于命令RGZPFM
  • 原文地址:https://www.cnblogs.com/mudy/p/4831587.html
Copyright © 2011-2022 走看看