zoukankan      html  css  js  c++  java
  • UIImageView的简单使用

     1 - (void)viewDidLoad {
     2     [super viewDidLoad];
     3     //将图片转化为UIImage对象
     4     //png格式不需要加扩展名,其它格式图片需要
     5     UIImage* image1 = [UIImage imageNamed:@"a"];
     6     UIImage* image2 = [UIImage imageNamed:@"b"];
     7     
     8     UIImageView* imageV = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 70)];
     9     [self.view addSubview:imageV];
    10     //设置背景颜色
    11     imageV.backgroundColor = [UIColor orangeColor];
    12     //设置显示的图片
    13     imageV.image = image1;
    14     //改变图片填充方式
    15     //UIViewContentModeScaleAspectFit,等比例缩放,图片不变形
    16     //UIViewContentModeScaleAspectFill,等比例填充,填满
    17     imageV.contentMode = UIViewContentModeScaleAspectFit;
    18     //切除超出部分
    19 //    imageV.clipsToBounds = YES;
    20     
    21     //设置高亮图片
    22     imageV.highlightedImage = image2;
    23     imageV.highlighted = YES;
    24     
    25     
    26     //动画数组
    27     UIImageView* animateImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 190)];
    28     [self.view addSubview:animateImageView];
    29     //创建动画数组
    30     NSMutableArray* animateImages = [[NSMutableArray alloc] init];
    31     
    32     for (int i = 1; i < 22; i++) {
    33         //记得加扩展名(.jpg)
    34         NSString* imageName = [NSString stringWithFormat:@"%d.jpg",i];
    35         UIImage* image = [UIImage imageNamed:imageName];
    36         [animateImages addObject:image];
    37     }
    38     //设置需要播放的动画(图片数组)
    39     animateImageView.animationImages = animateImages;
    40     //设置动画时间
    41     animateImageView.animationDuration = 2;
    42     //设置重复次数(0是一直重复)
    43     animateImageView.animationRepeatCount = 0;
    44     
    45     //开始动画
    46     [animateImageView startAnimating];
    47     
    48     
    49 }
  • 相关阅读:
    Android-MediaProvider数据库模式
    java String.getBytes()编码问题——String.getBytes(charset)
    设置Eclipse中的tab键为4个空格的完整方法
    linux下的zip命令
    关于facebook infer 静态代码审查工具
    关于软件测试人员能力模型的建立(from知乎)
    [ 转] 漫谈iOS Crash收集框架
    iOS开发如何提高(from 唐巧的博客)
    c++ web服务器
    小米开源监控系统的说明文档
  • 原文地址:https://www.cnblogs.com/qiulilin/p/4592044.html
Copyright © 2011-2022 走看看