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

Creates and returns a new image object with the specified cap values.

Deprecation Statement
Deprecated. Use the resizableImageWithCapInsets: instead, specifying cap insets such that the interior is a 1x1 area.

Declaration
SWIFT
func stretchableImageWithLeftCapWidth(_ leftCapWidth: Int,
                         topCapHeight topCapHeight: Int) -> UIImage
OBJECTIVE-C
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth
                                 topCapHeight:(NSInteger)topCapHeight
Parameters
leftCapWidth    
The value to use for the left cap width. Specify 0 if you want the entire image to be horizontally stretchable. For a discussion of how a non-zero value affects the image, see the leftCapWidth property.
topCapHeight    
The value to use for the top cap width. Specify 0 if you want the entire image to be vertically stretchable. For a discussion of how a non-zero value affects the image, see the topCapHeight property.
Return Value
A new image object with the specified cap values.

Discussion
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.

You use this method to add cap values to an image or to change the existing cap values of an image. In both cases, you get back a new image and the original image remains untouched.

Import Statement
OBJECTIVE-C
@import UIKit;
SWIFT
import UIKit
Availability
Available in iOS 2.0 and later.
Deprecated in iOS 5.0.

stackoverflow中的注释相关信息http://stackoverflow.com/questions/12623961/stretch-background-image-for-uibutton/12625066#12625066

ios中图片拉伸用法的更多相关文章

  1. IOS中图片拉伸技巧与方法总结(转载)

    以下内容转载自:http://my.oschina.net/u/2340880/blog/403996 IOS中图片拉伸技巧与方法总结 一.了解几个图像拉伸的函数和方法 1.直接拉伸法 简单暴力,却是 ...

  2. iOS中图片拉伸,类似Android中的点9图片

    UIImage* img=[UIImage imageNamed:@"name.png"];//原图 UIEdgeInsets edge=UIEdgeInsetsMake(, , ...

  3. ios中图片的绘画和截图

    ios中图片的绘画和截图 CGImageCreateWithImageInRect截图和UIGraphicsGetImageFromCurrentImageContext绘画图片 使用CGImageC ...

  4. 谈谈 iOS 中图片的解压缩

    原文 对于大多数 iOS 应用来说,图片往往是最占用手机内存的资源之一,同时也是不可或缺的组成部分.将一张图片从磁盘中加载出来,并最终显示到屏幕上,中间其实经过了一系列复杂的处理过程,其中就包括了对图 ...

  5. 【转】谈谈 iOS 中图片的解压缩

    转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...

  6. iOS中block的用法 以及和函数用法的区别

    ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候  MyBlock(); 带参数的 ...

  7. IOS中图片加载的一些注意点

    图片的加载: [UIImage imageNamed:@"home"] //加载 png图片 在ios中获取一张图片只需要写图片名即可 不需要写后缀 默认都是加载.png的图片 但 ...

  8. 我的Android最佳实践之—— ImageView中图片拉伸显示

    通过设置android:scaleType="fitXY"使得图片拉伸显示.补充:scaleType的属性有matrix(默认).center.centerCrop.centerI ...

  9. ios UIImage图片拉伸 resizableImageWithCapInsets:

    常见的按钮添加和背景设置如下: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(80, 130, 160, 44)];[bu ...

随机推荐

  1. Ansible-Tower快速入门-6.查看tower的仪表板【翻译】

    查看tower的仪表板 到这一步,我们已经可以在屏幕上看到tower的仪表板了,我们可以看到你目前"主机""资产清单"和"项目"的汇总信息, ...

  2. android中常用转义字符

    转义字符 实际字符 名称 < < 小于号 > > 大于号 & & 和 &apos; ' 单引号 " " 双引号  

  3. win32自绘按钮,使用GDI+(三)

    解决前面的问题.实现鼠标移动进入到按钮的特效. 效果是这样的 鼠标移到按钮上,改变按钮的颜色(这里用的是直接换贴在按钮上的图片) 程序运行 鼠标进入按钮 代码 #ifndef ULONG_PTR // ...

  4. 关于raid的理解

    缘起 公司部署业务的时候,6块盘需要做raid,以前还没有用过所以不知道,临时才去百度看了一下相关知识. 部署 当前可以用软raid与硬raid,软raid系统上建立,占用CPU与IO资源;硬RAID ...

  5. Array.splice()理解记忆

    var arr = [0,1,2,3,4,5,6,7,8,9]; arr.splice(0,0,"添加项1"); //arr => ["添加项",0,1, ...

  6. 优先队列 :Priority Queue

    PriorityQueue是从JDK1.5开始提供的新的数据结构接口,它是一种基于优先级堆的极大优先级队列.优先级队列是不同于先进先出队列的另一种队列. 每次从队列中取出的是具有最高优先权的元素.如果 ...

  7. 前后台数据交互 后台封装数据 json格式

    namespace ~.sverIterface { public class EventPlayerInfo { public string name { get; set; } public st ...

  8. JavaScript面向对象,及面向对象的特点,和如何构造函数

    1.面向对象和面向过程的区别 面向过程就是分析出解决问题所需要的步骤,然后用函数把这些步骤一步一步实现,使用的时候一个一个依次调用就可以了: 面向对象是把构成问题事务分解成各个对象,建立对象的目的不是 ...

  9. 《Android深度探索HAL与驱动开发》第四章阅读心得

     Android源代码包含了很多内容,可以实现拍照.计算机.日历.相册.拨号器等功能.配置Android源代码下载环境需要如下几步: (1)创建一个用于存放下载脚本文件的目录:  (2)下载repo脚 ...

  10. RY哥查字典

    时间限制: 1 s 空间限制: 16000 KB 题目等级 : 钻石 Diamond 题目描述 Description RY哥最近新买了一本字典,他十分高兴,因为这上面的单词都十分的和谐,他天天查字典 ...