图片的展示
2016-08-26 11:10
246 查看
图片分可点击和不可点击
可点击图片一般使用UIButton显示,不可点击一般使用UIImageView显示,现在具体说说其中的一些属性和区别,
1,UIButton,
传说中的按钮,按钮显示图片分backgroundImage和image二中,
UIButton *pButton = [[UIButton alloc] init];
UIImage *pImage;
//设置按钮上的图片,图片按比例饿显示
[pButton setImage:pImage forState:UIControlStateNormal];
//设置按钮背景,图片会被拉伸充满整个button
[pButton setBackgroundImage:pImage forState:UIControlStateNormal];
2,UIImageView
UIImageView *pImageView = [[UIImageView alloc] init];
pImageView.image = pImage;
//设置图片的现实方式
pImageView.contentModel = UIViewContentModeScaleAspectFill;
//UIViewContentModeScaleToFill:铺满,图片可能被拉伸
//UIViewContentModeScaleAspectFit:适应显示,周边可能有空白出现
//UIViewContentModeScaleAspectFill:正常显示,图片可能超出范围
//超出部分不显示
pImageView.clipsToBounds = YES;
相关文章推荐
- 按右键另存图片只能存BMP
- photoshop去除图片上的水印
- upload上传单张图片
- 图片引发的溢出危机(图)
- C# WinForm控件对透明图片重叠时出现图片不透明的简单解决方法
- C#实现把彩色图片灰度化代码分享
- C#将图片和字节流互相转换并显示到页面上
- C#监控文件夹并自动给图片文件打水印的方法
- 纯CSS实现的当鼠标移上图片添加阴影效果代码
- 如何使用C#从word文档中提取图片
- C#实现打开画图的同时载入图片、最大化显示画图窗体的方法
- C#图片添加水印的实现代码
- 随鼠标移动的图片或文字特效代码
- CSS 图片横向排列实现代码
- C#实现将Email地址转成图片显示的方法
- C#实现图片加相框的方法
- 超级经典一套鼠标控制左右滚动图片带自动翻滚
- 用css实现图片垂直居中的使用技巧
- 一起动手编写Android图片加载框架
- VC++实现View内容保存为图片的方法