iOS学习(UIImageView)
2015-07-31 22:20
363 查看
5.UIImageView是展示图片的一种控件
1).初始化
UIImageView *imageView = [[UIImageView
alloc]
init];
2).调整尺寸大小
imageView.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.width);
3).调整背景颜色
imageView.backgroundColor = [UIColor
whiteColor];
4).调整图片在的位置
imageView.center =
self.view.center;(这里的view是从windows里获取的)
5).获取图片到imageView
imageView.image = image(image是我们住呢比好的图片对象)
6).uiview的属性,设置为yes的时候超出部分,不予以显示
imageView.clipsToBounds =
YES;
7).UIImageView几种填充模式
<1>UIViewContentModeScaleToFill
拉伸image使其充满UIImageView
<2>UIViewContentModeScaleAspectFill
拉伸image使其不变形,并且充满UIImageView
<3>UIViewContentModeScaleAspectFit
拉伸imgage使其不变形,并且完全显示在UIImageView中
如果有Scale属性,图片都会被拉伸
8).UIImageView和button一样都有触发事件
imageView.userInteractionEnabled =
YES;(打开imageview的用户交互)
UITapGestureRecognizer *tap = [[UITapGestureRecognizer
alloc]
initWithTarget:self
action:@selector(imageViewTapped:)];
[imageView addGestureRecognizer:tap];(点击手势)
;
1).初始化
UIImageView *imageView = [[UIImageView
alloc]
init];
2).调整尺寸大小
imageView.frame =
CGRectMake(0,
0, self.view.frame.size.width,
self.view.frame.size.width);
3).调整背景颜色
imageView.backgroundColor = [UIColor
whiteColor];
4).调整图片在的位置
imageView.center =
self.view.center;(这里的view是从windows里获取的)
5).获取图片到imageView
imageView.image = image(image是我们住呢比好的图片对象)
6).uiview的属性,设置为yes的时候超出部分,不予以显示
imageView.clipsToBounds =
YES;
7).UIImageView几种填充模式
<1>UIViewContentModeScaleToFill
拉伸image使其充满UIImageView
<2>UIViewContentModeScaleAspectFill
拉伸image使其不变形,并且充满UIImageView
<3>UIViewContentModeScaleAspectFit
拉伸imgage使其不变形,并且完全显示在UIImageView中
如果有Scale属性,图片都会被拉伸
8).UIImageView和button一样都有触发事件
imageView.userInteractionEnabled =
YES;(打开imageview的用户交互)
UITapGestureRecognizer *tap = [[UITapGestureRecognizer
alloc]
initWithTarget:self
action:@selector(imageViewTapped:)];
[imageView addGestureRecognizer:tap];(点击手势)
;
相关文章推荐
- ubuntu下vagrant up经常出现Failed to upload a file to the guest VM via SCP due to a permissions error.最终解决
- hdu 5297 Y sequence(容斥)
- 黑马程序员------API(String类,StringBuffer,StringBuilder及基本数据类型包装类)
- Entityframework~Fluent Api配置数据模型与数据库结构关系
- mysql启动错误:Starting MySQL.. ERROR! The server quit without updating PID file错误
- 递归和循环---从EasyUI Tree 发现自己的硬伤
- uva11235 Frequent values(线段树区间合并)
- LTView 自定义视图 UIAlertView
- EasyUi 新组件 switchbutton 根据状态切换显示内容
- Android API Guides 阅读笔记(9)----Bound Service
- UVA1152-4 Values whose Sum is 0
- UIViewController(视图控制器)下的View切换
- UVA1605-Building for UN
- 仿Uber主界面布局,框架简单实现
- iOS-01-UILabel
- PcDuino初学分享
- BlockingQueue中add,offer,put方法区别
- cmsis-rtos v1.02支持Mail Queue问题
- [UVA11572]Unique Snowflakes[构造]
- UIScrollView的属性总结