UI_UIImageViw(图片)

  /**
     *  关于图片加载的两种方式:
     *
     *      1:APP启动就将图片全部读进内存,加载图片会很快,但是图片有多大会占用内存,应用所能占用的内存是有一定限制的
     *      2:使用时,从磁盘读取图片文件,相对内存读取会稍稍慢一点,但没有什么大碍
     *
     *  两种使用环境:
     *       1..频繁使用的小图片,用读进内存的方法。
     *      2..不常用的大图片,用现读文件的方法
     *
     *  举例:一个Table,每个Cell都有一个下载按钮的图片,用读进内存的方法.
     *     应用有几页引导页面(全屏大小),现读文件
     */

    UIImage *secondImage = [UIImage imageNamed:@"1_1.png"];
    UIImage *thirdImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1_2" ofType:@"png"]];
   
    
    
    
    UIImageView *secondImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 360, 171)];
    secondImageView.image = secondImage;

//1、根据读进来的图片的大小来确认image
    UIImageView *thirdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 200, thirdImage.size.width, thirdImage.size.height)];
    thirdImageView.image = thirdImage;

    
//2、UIImageView的动画
    NSMutableArray *picArr = [NSMutableArray arrayWithCapacity:0];
    for(int i =1;i<13;i++)
    {//数组里存的是UIImage对象,不是图片名字符串
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"player%d.png",i]];
        [picArr addObject:image];
    }
    
//3..将多张图片开始播放
//    1、实例化一个UIImageView
//    2、把要动画的图片Image用数组赋值
//    3、动画持续时长,是一轮的时长
//    4、重复轮数 0表示无限次
//    5、准备完成后,开始轮播
    UIImageView *animateImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 400, 60, 60)];
    animateImage.animationImages = picArr;
    animateImage.animationDuration = 0.5;
    animateImage.animationRepeatCount = 0;
    [self.view addSubview:animateImage];
    [animateImage startAnimating];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值