zoukankan      html  css  js  c++  java
  • iOS-- UIimageView详解

    原文地址: http://blog.csdn.net/djxiaoyu_haha/article/details/40348377

    //    (1)创建
    
        UIImageView *imageView = [[UIImageView alloc ] init];
    
        
    
     
    
        UIImage *image = [UIImage imageNamed:@"image_photo"];
    
        imageView.image = image;
    
        
    
        //    (2)设置圆角
    
        imageView.layer.masksToBounds = YES;
    
        imageView.layer.cornerRadius = 10;
    
        
    
        
    
        //    (3)设置边框颜色和大小
    
        imageView.layer.borderColor = [UIColor orangeColor].CGColor;
    
        imageView.layer.borderWidth = 2;
    
        
    
        
    
        //    (4)contentMode属性:当图片小于imageView的大小处理图片显示
    
     
    
     
    
        //    这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有以下几个常量可供设定:
    
        //
    
        //    UIViewContentModeScaleToFill :填充整个UIViewContentModeScaleAspectFit UIViewContentModeScaleAspectFill UIViewContentModeRedraw UIViewContentModeCenter UIViewContentModeTop UIViewContentModeBottom UIViewContentModeLeft UIViewContentModeRight UIViewContentModeTopLeft UIViewContentModeTopRight UIViewContentModeBottomLeft UIViewContentModeBottomRight
    
        imageView.contentMode = UIViewContentModeScaleAspectFit;
    
        
    
        
    
        //(5)播放一系列图片
    
        UIImage *image1 = [UIImage imageNamed:@"homeNaviLeftBtn"];
    
        UIImage *image2 = [UIImage imageNamed:@"homeNaviRightBtn"];
    
        UIImage *image3 = [UIImage imageNamed:@"image_photo"];
    
        NSArray *imagesArray = @[image1,image2,image3];
    
        imageView.animationImages = imagesArray;
    
        // 设定所有的图片在多少秒内播放完毕
    
        imageView.animationDuration = [imagesArray count];
    
        // 不重复播放多少遍,0表示无数遍
    
        imageView.animationRepeatCount = 0;
    
        // 开始播放
    
        [imageView startAnimating];
    
        
    
        
    
        
    
         //(6)为图片添加单击事件:一定要先将userInteractionEnabled置为YES,这样才能响应单击事件
    
        
    
        imageView.userInteractionEnabled = YES;
    
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizeralloc] initWithTarget:self action:@selector(tapImageView:)];
    
        [imageView addGestureRecognizer:singleTap];
    
        
    
        
    
        
    
        //(7)其他设置
    
        
    
    //    imageView.hidden = YES或者NO;    // 隐藏或者显示图片
    
        imageView.alpha =0.5;    // 设置透明度
    
        // 设置高亮时显示的图片
    
        //imageView.highlightedImage = (UIImage *)hightlightedImage;
    
        
    
         //imageView.image = (UIImage *)image; // 设置正常显示的图片
    
     
    
       
    
        
    
        //设置位置 1)修改center ImageView的中间点2)修改frame
    
        imageView.frame = CGRectMake(10, 66, 300, 400);
    
    //    imageView.center = CGPointMake(0, 0);
  • 相关阅读:
    eureka 注册中心(单机版)
    金蝶实际成本培训01
    查看WIN10内核
    金蝶K3 WISE 15.0 GUID
    win10卸载系统自带office365
    金蝶K3wise15.0BOM维护默认只能查看登录账户作为建立人的BOM清单
    阿里云邮箱代收邮件
    金蝶寄售业务流程
    转-商品流通企业代销商品核算方法
    转-ERP待检仓、代管仓、赠品仓
  • 原文地址:https://www.cnblogs.com/mafeng/p/5676537.html
Copyright © 2011-2022 走看看