IOS图片拉伸的方法 UIImage stretchableImageWithLeftCapWidth:leftCapWidth:topCapHeight
来源:互联网 发布:linux查看目录 编辑:程序博客网 时间:2024/05/16 10:51
IOS图片拉伸的方法很简单,qi
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
这个函数是UIImage的一个实例函数,它的功能是创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是不拉伸区域和左边框的宽度,第二个参数是不拉伸区域和上边框的宽度。
第一次用这个函数的时候一直搞不懂为什么只要两个参数就行,至少应该指定左上角和右下角,总共四个参数啊。后来读读文档才明白,只需要两个参数就行了。
参数的意义是,如果参数指定10,5。那么,图片左边10个像素,上边5个像素。不会被拉伸,x坐标为11和一个像素会被横向复制,y坐标为6的一个像素会被纵向复制。
注意:只是对一个像素进行复制到一定宽度。
----------------------------------------
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapWidth;
Creates and returns a new image object with the specified cap values.
During scaling or resizing of the image, areas covered by a cap are not scaled or resized. Instead, the 1-pixel wide area not covered by the cap in each direction is what is scaled or resized. This technique is often used to create variable-width buttons, which retain the same rounded corners but whose center region grows or shrinks as needed.
上面是官方文档上得解释。意思就是用来创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是左边不拉伸区域的宽度,第二个参数是上面不拉伸的高度。那么接下来的一个像素会被拉伸。例如,leftCapHeight为6,topCapHeight为8。那么,图片左边的6个像素,上边的8个像素。不会被拉伸,而左边的第7个像素,上边的第9个像素这一块区域将会被拉伸。剩余的部分也不会被拉伸。
----------------------------------------
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:
(NSInteger)topCapHeight 这个函数是UIImage的一个实例函数,它的功能是创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是左边不拉伸区域的宽度,第二个参数是上面不拉伸的高度。
根据设置的宽度和高度,将接下来的一个像素进行左右扩展和上下拉伸。
注意:可拉伸的范围都是距离leftCapWidth后的1竖排像素,和距离topCapHeight后的1横排像素。
参数的意义是,如果参数指定10,5。那么,图片左边10个像素,上边5个像素。不会被拉伸,x坐标为11和一个像素会被横向复制,y坐标为6的一个像素会被纵向复制。
注意:只是对一个像素进行复制到一定宽度。而图像后面的剩余像素也不会被拉伸。
UIImage *img=[UIImage imageNamed:@"bubbleSelf.png"];
img=[img stretchableImageWithLeftCapWidth:15 topCapHeight:12];
UIImageView *imgView=[[UIImageView alloc]initWithImage:img];
[imgView setFrame:CGRectMake(10, 10, 200, 200)];
[self. view addSubview:imgView];
- IOS图片拉伸的方法 UIImage stretchableImageWithLeftCapWidth:leftCapWidth:topCapHeight
- - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap
- - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCap
- - (UIIMAGE *)STRETCHABLEIMAGEWITHLEFTCAPWIDTH:(NSINTEGER)LEFTCAPWIDTH TOPCAPHEIGHT:(NSINTEGER)TOPCAP
- - (UIImage*)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapH
- stretchableImageWithLeftCapWidth:leftCapWidth topCapHeight:
- iOS图像拉伸,stretchableImageWithLeftCapWidth:topCapHeight:
- iPhone图片拉伸:stretchableImageWithLeftCapWidth:topCapHeight && resizableImageWithCapInsets
- 关于- (UIImage *)stretchableImageWithLeftCapWidth: topCapHeight:
- ios之图片的拉伸、UIImageView的stretchableImageWithLeftCapWidth方法详解
- iOS UIImage部分拉伸——stretchableImageWithLeftCapWidth的使用
- 图片拉伸处理:stretchableImageWithLeftCapWidth方法的使用
- 关于stretchableImageWithLeftCapWidth:topCapHeight:方法的原理介绍
- 关于stretchableImageWithLeftCapWidth:topCapHeight方法的原理
- 关于stretchableImageWithLeftCapWidth:topCapHeight方法的原理
- IOS uiimage 拉伸的方法
- iOS-UIImage图片拉伸
- stretchableImageWithLeftCapWidth:topCapHeight:函数用法 总结 (UIImage)
- 设计模式:抽象工厂模式(Abstract Factory Pattern)
- java Bundle&Properties
- keystone
- test8.3
- c++调用winhttp对象
- IOS图片拉伸的方法 UIImage stretchableImageWithLeftCapWidth:leftCapWidth:topCapHeight
- 突然发现,我还有一个失散多年的blog,好吧,相逢不如偶遇,临~幸你一次吧。(图片浏览器)
- Junior_week2 summarization
- centos LAMP搭建
- php SOAP之多层complex类型
- android中实现截屏的三种思路
- android listview divider padding
- SurfaceView和view分别实现触摸轨迹
- 喷水装置 ACM题目 京东16招聘编程题(贪心算法)