//    (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 = [[UITapGestureRecognizer alloc] 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);

IOS-UIImageView相关推荐

  1. iOS UIImageView 加载含有汉字的url处理方法

    NSString *url = [model.pic stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet  URLQu ...

  2. ios 图片居中裁剪_iOS 根据UIImage 修改UIImageView Frame (包括截取图片中间部分)...

    iOS UIImageView 根据需求调整frame 1.图片的宽和高不相等,截取图片的中间部分,截取的部分Size明确 2.图片的宽度要等于其父视图的类的宽度,然后根据宽度计算高度,保证 图片不变 ...

  3. iOS - Core Animation 核心动画

    1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...

  4. sparksql内写linux脚本,shell脚本调用spark-sql

    IOS UIImageView的contentMode属性 红框表示imageView的frame,下面的图片是原图大小UIViewContentModeScaleToFill,       默认,对 ...

  5. swift 将图片保存到本地_swift 图片存储到本地文件的搜索结果-阿里云开发者社区...

    iOS - UIImageView 前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIImageView : UIView @available(iOS 2.0, ...

  6. 【IOS 开发】基本 UI 控件详解 (UISegmentedControl | UIImageView | UIProgressView | UISlider | UIAlertView )

    转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50163725 一. 分段控件 (UISegmentedControl) 控件展 ...

  7. iOS开发(7)通过uiimageView浅谈UIView

    基本上,每一个IOS控件都有自己的VIew,View就是显示到屏幕上的视图.而屏幕就相当于显示各种View的容器.就好像是一个画家在自己的画布上写东西,很有意义把?  一个画家要想画出漂亮的东西就需要 ...

  8. ios开发(6)uiimageView

    在IOS的控件中,UIImageView是一个显示图片的容器试图. 下面介绍一下基本属性 //uiimageview初始化有六种方式 一般常用为三种 根据需要选择以坐标初始化还是以照片 UIImage ...

  9. 给iOS项目中添加图片,并通过UIImageView引用和显示该UIImage图片

    [问题] 关于iOS/iPhone中的文件选择对话框,用于用户去选择图片等文件 过程中,问题转换为,需要给当前iOS项目中,添加一个图片. 类似于Windows开发中的资源文件,其中图片文件属于资源的 ...

  10. iOS图片显示模式(UIImageView)

    UIImageView来显示图片的时候,经常会遇到图片变形.图片显示不全.留下空白等问题,本文就讲解一下图片显示模式,来适应图片的填充.下面的讲解我会用红色框当做控件范围,绿色框当做图片尺寸去讲解.( ...

最新文章

  1. mysql备份psb文件怎么打开_Navicat for MySQL 数据备份教程
  2. svn working copy locked
  3. javascript闭包简单实例
  4. python2.7安装matplotlib_Python安装Numpy和matplotlib
  5. 解决网页中不能复制文字的问题
  6. SpringMVC 生成json报 HTTP Status 406.错误的解决方法
  7. 链表最终总结【数据结构】
  8. OpenSsl工具的介绍
  9. VS 2012 单元测试简单配置
  10. 深入浅出带你了解Python2与Python3的异同
  11. json文件存储 qt_QT开发(五十一)——QtQuick基础
  12. chown –r mysql:mysql_Linux服务器部署系列之二—MySQL篇
  13. 在CSDN开通博客专栏后如何发布文章及改进建议(图文)
  14. 谷歌浏览器截图_【插件推荐】一键滚动截图整个网页,支持二次编辑的免费工具...
  15. C#winform之自定义按钮形状(初级版)
  16. hexo个人next主题博客接入谷歌广告
  17. 思考与总结:数据分片的一些问题
  18. 基于时间序列特征提取的车载网络系统入侵检测技术
  19. 教你高效修改文件夹名称,将首写字母改为大写
  20. 关于JAVA外包的解释及优劣势

热门文章

  1. linux_Flatpak
  2. 技术解读 | 科大讯飞语音技术最新进展之二:语音识别与语音合成
  3. 华师大 OJ 3037
  4. 【汇正财经】什么是成长投入策略?
  5. erron变量、strerror函数 和 perror 函数
  6. ARM内核全解析,从ARM7 ARM9到Cortex-A7 A8 Cortex-A53 A57 A72
  7. WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web appli
  8. selenium工作原理详解
  9. 智慧水务综合管理平台解决方案,助力水司数字化管理
  10. 迅雷导出ed2k到eMule链接无效处理