imageView的使用
2024-08-30 20:49:04
转自: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];
}
最新文章
- PYTHON 深拷贝,浅拷贝
- Go 中的反射要点
- 修饰者模式(装饰者模式,Decoration)
- IIS 8.5配置.net网站[花了半个多小时]
- ASP.NET MVC- DropDownList绑定
- error: /usr/include/objc/objc-class.h: No such file or directory
- BZOJ3296: [USACO2011 Open] Learning Languages
- 热部署环境下,dubbo序列化的bug和优化
- java中队列Queue的使用
- Aooms_微服务基础开发平台实战_002_工程构建
- C#在截屏时将截屏之前需要隐藏的控件也截入
- VS2013 ";当前不会命中断点.还没有为该文档家在任何符号"; 解决办法
- leetcode315
- JEECG 3.7.3 新春版本发布,企业级JAVA快速开发平台
- 面向对象多继承(c3算法)、网络基础和编写网络相关的程序
- 一文读懂BERT中的WordPiece
- 149. Max Points on a Line (Array; Greedy)
- 排序算法(2) 堆排序 C++实现
- Java进阶知识点:更优雅地关闭资源 - try-with-resource
- SqlServer查看对象(表、存储过程、函数)在哪些地方被引用或引用哪些地方
热门文章
- 搭建Redis三主三从集群
- 力扣(LeetCode)Excel表列序号 个人题解
- VLAN实验(2)Trunk接口
- 关于 “'sqlite3' 不是内部或外部命令.....”问题
- futex-based pthread_cond 源代码分析
- 在input输入值改变reducer里的值
- 在 Vue中使用layui日历控件,标注重要日子
- Entity Framework Core For MySql查询中使用DateTime.Now的问题
- 【Spring】简述@Configuration配置类注册BeanDefinition到Spring容器的过程
- oracle中两个服务器连接中sys密码修改问题