Day.02.24 UIImage

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor grayColor];
    
    //获取图片:图片名要加拓展名,png格式除外
    UIImage *image = [UIImage imageNamed:@"stop_red.JPG"];
    
    //图片的拉伸
    
    //CapInset 端盖
    //leftCap 水平拉伸的位置
    //topCap 垂直拉伸的位置
    
    //    UIImageResizingModeTile,   平铺
    //    UIImageResizingModeStretch   拉伸
    
    //1.创建一个imageView --> frame和image必备的
    UIImageView *imageView = [[UIImageView alloc]init];
    
        //默认图片
    imageView.image = image;
    
        //图片视图的frame
//    imageView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    
    imageView.frame = CGRectMake(0, 50, 300, 300);
    
        //标签
    imageView.tag = 100;
    
        //高亮图片:图片高亮状态下显示
    imageView.highlightedImage = [UIImage imageNamed:@"stop_yellow.JPG"];
    
    //是否开启高亮状态 默认NO

    
    //内容方式
    /*
     
     UIViewContentModeScaleToFill,    拉伸
     UIViewContentModeScaleAspectFit,    水平自适应
     UIViewContentModeScaleAspectFill,   垂直自适应
     UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)
     UIViewContentModeCenter,              // contents remain same size. positioned adjusted.
     UIViewContentModeTop,
     UIViewContentModeBottom,
     UIViewContentModeLeft,
     UIViewContentModeRight,
     UIViewContentModeTopLeft,
     UIViewContentModeTopRight,
     UIViewContentModeBottomLeft,
     UIViewContentModeBottomRight,
     */
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    
    
    /*
     
     CALayer 显示层属性
     */
    
    //圆角
//    imageView.layer.cornerRadius = 150;
    
    //边线:宽度
    imageView.layer.borderWidth = 5;
    
    //边线:颜色
    imageView.layer.borderColor = [[UIColor greenColor]CGColor];
    
    //边缘裁剪:超出范围的视图不显示
    imageView.clipsToBounds = YES;
    
    //3.添加到视图显示
    [self.view addSubview:imageView];
    
}
- (IBAction)animation:(id)sender {
    
    //1.图片数组
    NSMutableArray *array = [[NSMutableArray alloc]init];
    
        //遍历图片数组
    for (int i = 0; i < 13; i++) {
        
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"cat_cymbal00%02d.jpg",i]];
        
        [array addObject:image];
    }
    
    //2.设置动画数组
    UIImageView *imageView = [[UIImageView alloc]init];
    
        //设置图的大小
    imageView.frame = CGRectMake(0, 350, 200, 350);
    
        //返回
    [self.view addSubview:imageView];
    
    imageView.animationImages = array;
    
    //3.设置动画属性
    
        //播放时间
    imageView.animationDuration = 1;
    
        //重复次数,系统默认无限次
//    imageView.animationRepeatCount = 1;//出现错误断点查询
    
    
    //4.启动动画
    [imageView startAnimating];
    
    //5.停止动画
//    [imageView stopAnimating];//运行后不显示动画
    
    
}
- (IBAction)highlight:(id)sender {
    
    UIImageView *iv =  [self.view viewWithTag:100];
    
    //切换状态  聪明
    iv.highlighted =! iv.highlighted;
    
//    //笨点
//    if (iv.highlighted == NO) {
//        
//        iv.highlighted = YES;
//    }else{
//    
//        iv.highlighted = NO;
//    }
}

@end

lighted //点燃
highlighted //高亮
layer //层
clips //剪辑
bounds //界限
radius //半径
corner //角
cornerRadius //圆角

屏幕快照 2016-02-24 下午8.36.39.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容