IOS开发UIImage中stretchableImageWithLeftCapWidth方法的解释

- (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个像素这一块区域将会被拉伸。剩余的部分也不会被拉伸。

posted @ 2013-11-21 14:40  苹果吧  阅读(6240)  评论(0编辑  收藏  举报