UIView's contentStretch属性
2012-09-25 22:36
411 查看
UIView's contentStretch (view的伸和缩)
转贴出处:http://hi.baidu.com/jt_one/blog/item/937b6e81932a58c3bc3e1e9b.html
当图片大于imageV的大小时,图片就缩小。
当图片小于imageV的大小时,图片就放大。
放大:
imageView.image = [UIImage imageNamed:@"image.png"];
[imageView setContentStretch:CGRectMake(150.0/300.0,75.0/150.0,10.0/300.0,10.0/150.0)];
image.png的大小是 210.0 x 126.0 ;
imageView的frame是(9,117,300,150);
150.0/300.0表示x轴上,前150个像素不进行拉伸。
75.0/150.0表示y轴上,前75个像素不进行拉伸。
10.0/300.0表示x轴上150后的10个像素(151-160)进行拉伸,直到image.png铺满imageView。
10.0/150.0表示y轴上75后的10个(76-85)像素进行拉伸,直到image.png铺满imageView。
缩小:
image.png的大小是 210.0 x 126.0 ;
imageView的frame是(9,117,150,110);
imageView .image = [UIImage imageNamed:@"image.png"];
[ imageView setContentStretch:CGRectMake(50.0/150.0,
50.0/110.0,
(150-50.0*2)/150.0,
(110.0-50.0*2)/110.0)];
50.0/150.0表示x轴上,前50个像素不进行拉伸。
50.0/110.0表示y轴上,前50个像素不进行拉伸。
50/150.0表示x轴上50后的50个像素(51-100)进行拉伸,后面50像素没有拉伸。
10/150.0表示y轴上50后的10个(51-60)像素进行拉伸,后面50像素没有拉伸。
转贴出处:http://hi.baidu.com/jt_one/blog/item/937b6e81932a58c3bc3e1e9b.html
当图片大于imageV的大小时,图片就缩小。
当图片小于imageV的大小时,图片就放大。
放大:
imageView.image = [UIImage imageNamed:@"image.png"];
[imageView setContentStretch:CGRectMake(150.0/300.0,75.0/150.0,10.0/300.0,10.0/150.0)];
image.png的大小是 210.0 x 126.0 ;
imageView的frame是(9,117,300,150);
150.0/300.0表示x轴上,前150个像素不进行拉伸。
75.0/150.0表示y轴上,前75个像素不进行拉伸。
10.0/300.0表示x轴上150后的10个像素(151-160)进行拉伸,直到image.png铺满imageView。
10.0/150.0表示y轴上75后的10个(76-85)像素进行拉伸,直到image.png铺满imageView。
缩小:
image.png的大小是 210.0 x 126.0 ;
imageView的frame是(9,117,150,110);
imageView .image = [UIImage imageNamed:@"image.png"];
[ imageView setContentStretch:CGRectMake(50.0/150.0,
50.0/110.0,
(150-50.0*2)/150.0,
(110.0-50.0*2)/110.0)];
50.0/150.0表示x轴上,前50个像素不进行拉伸。
50.0/110.0表示y轴上,前50个像素不进行拉伸。
50/150.0表示x轴上50后的50个像素(51-100)进行拉伸,后面50像素没有拉伸。
10/150.0表示y轴上50后的10个(51-60)像素进行拉伸,后面50像素没有拉伸。
相关文章推荐
- 如何在aodv协议中访问node的各项属性
- Hibernate3.2.6 原生sql 查询使用方法,将查询结果直接转换为POJO,不必非要指定属性大写
- 控制span的width属性且不换行
- 【实用】linux文件属性详细说明
- struts---如何去增添request/session/application的属性(13)
- 数据库连接-使用属性文件做数据库的连接
- android:scaleType属性 图片在imagebutton中自适应
- 3.2.8: 属性操作
- setWindowFlags参数的属性
- ServiceMetadataBehavior 的 HttpsGetEnabled 属性设置为 True,而 HttpsGetUrl 属性是相对地址,但没有 https 基址。
- Hibernate进阶篇(一)——hibernate.cfg.xml常用配置属性
- 【转】RelativeLayout用到的一些重要的属性
- 手势的3个容易混淆的属性 cancelsTouchesInView/delaysTouchesBegan/delaysTouchesEnded
- layout_weight属性解析
- RecyclerView中的item的match_parent属性失效问题解决方案
- 4.Spring学习笔记_属性配置细节(by尚硅谷_佟刚)
- android中屏幕方向screenOrientation属性详解
- 删除和添加标签属性之prop和attr
- 组件属性
- Java实体类属性动态替换