- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapWidth

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • // //UIView.h //UIKit // //Copyright (c) 2005-2015 Apple ...
    李某lkb阅读 1,748评论 0 0
  • ImageMagick学习之 The Definitive Guide To ImageMagick The De...
    焉知非鱼阅读 1,342评论 0 2
  • 从黑暗中惊醒,已经记不得梦中的内容,还留有余温的泪珠顺着双颊滑落,不知道这是最近哭的第几次了,内心纠疼着却成了麻木...
    九瓶阅读 941评论 6 6
  • 旷野有风四面八方 来自人群、森林和深达八万里的海洋 谁在咆哮 说自己无处躲藏 旷野的野花都凋零了 干蓬的枯枝在闪电...
    Nora小碗阅读 345评论 1 2
  • 他们已经上了年纪,在日常的琐碎之中恍然间发现自己的激情已随风而逝,坐在公交站台旁,目不斜视地盯着不远处的车子滑过,...
    须荌阅读 218评论 0 0