转自:http://www.runoob.com/ios/att-ios-ui-imageview.html

图像视图用于显示单个图像或动画序列的图像。

重要的属性

  • image
  • highlightedImage
  • userInteractionEnabled
  • animationImages
  • animationRepeatCount

重要的方法

- (id)initWithImage:(UIImage *)image
- (id)initWithImage:(UIImage *)image highlightedImage:
(UIImage *)highlightedImage
- (void)startAnimating
- (void)stopAnimating

添加自定义方法 addImageView

-(void)addImageView{
UIImageView *imgview = [[UIImageView alloc]
initWithFrame:CGRectMake(10, 10, 300, 400)];
[imgview setImage:[UIImage imageNamed:@"AppleUSA1.jpg"]];
[imgview setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:imgview];
}

添加另一个自定义方法 addImageViewWithAnimation

这种方法解释了如何对imageView 中的图像进行动画处理

-(void)addImageViewWithAnimation{
UIImageView *imgview = [[UIImageView alloc]
initWithFrame:CGRectMake(10, 10, 300, 400)];
// set an animation
imgview.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"AppleUSA1.jpg"],
[UIImage imageNamed:@"AppleUSA2.jpg"], nil];
imgview.animationDuration = 4.0;
imgview.contentMode = UIViewContentModeCenter;
[imgview startAnimating];
[self.view addSubview:imgview];
}

注意: 我们必须添加命名为"AppleUSA1.jpg"和"AppleUSA2.jpg"到我们的项目,可以通过将图像拖到我们导航区域,其中列出了我们的项目文件所做的图像。

在 ViewController.m 中更新 viewDidLoad,如下所示

(void)viewDidLoad
{
[super viewDidLoad];
[self addImageView];
}

最新文章

  1. PYTHON 深拷贝,浅拷贝
  2. Go 中的反射要点
  3. 修饰者模式(装饰者模式,Decoration)
  4. IIS 8.5配置.net网站[花了半个多小时]
  5. ASP.NET MVC- DropDownList绑定
  6. error: /usr/include/objc/objc-class.h: No such file or directory
  7. BZOJ3296: [USACO2011 Open] Learning Languages
  8. 热部署环境下,dubbo序列化的bug和优化
  9. java中队列Queue的使用
  10. Aooms_微服务基础开发平台实战_002_工程构建
  11. C#在截屏时将截屏之前需要隐藏的控件也截入
  12. VS2013 "当前不会命中断点.还没有为该文档家在任何符号" 解决办法
  13. leetcode315
  14. JEECG 3.7.3 新春版本发布,企业级JAVA快速开发平台
  15. 面向对象多继承(c3算法)、网络基础和编写网络相关的程序
  16. 一文读懂BERT中的WordPiece
  17. 149. Max Points on a Line (Array; Greedy)
  18. 排序算法(2) 堆排序 C++实现
  19. Java进阶知识点:更优雅地关闭资源 - try-with-resource
  20. SqlServer查看对象(表、存储过程、函数)在哪些地方被引用或引用哪些地方

热门文章

  1. 搭建Redis三主三从集群
  2. 力扣(LeetCode)Excel表列序号 个人题解
  3. VLAN实验(2)Trunk接口
  4. 关于 “'sqlite3' 不是内部或外部命令.....”问题
  5. futex-based pthread_cond 源代码分析
  6. 在input输入值改变reducer里的值
  7. 在 Vue中使用layui日历控件,标注重要日子
  8. Entity Framework Core For MySql查询中使用DateTime.Now的问题
  9. 【Spring】简述@Configuration配置类注册BeanDefinition到Spring容器的过程
  10. oracle中两个服务器连接中sys密码修改问题