ios中图片拉伸用法
- (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中图片拉伸用法的更多相关文章
- IOS中图片拉伸技巧与方法总结(转载)
以下内容转载自:http://my.oschina.net/u/2340880/blog/403996 IOS中图片拉伸技巧与方法总结 一.了解几个图像拉伸的函数和方法 1.直接拉伸法 简单暴力,却是 ...
- iOS中图片拉伸,类似Android中的点9图片
UIImage* img=[UIImage imageNamed:@"name.png"];//原图 UIEdgeInsets edge=UIEdgeInsetsMake(, , ...
- ios中图片的绘画和截图
ios中图片的绘画和截图 CGImageCreateWithImageInRect截图和UIGraphicsGetImageFromCurrentImageContext绘画图片 使用CGImageC ...
- 谈谈 iOS 中图片的解压缩
原文 对于大多数 iOS 应用来说,图片往往是最占用手机内存的资源之一,同时也是不可或缺的组成部分.将一张图片从磁盘中加载出来,并最终显示到屏幕上,中间其实经过了一系列复杂的处理过程,其中就包括了对图 ...
- 【转】谈谈 iOS 中图片的解压缩
转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...
- iOS中block的用法 以及和函数用法的区别
ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候 MyBlock(); 带参数的 ...
- IOS中图片加载的一些注意点
图片的加载: [UIImage imageNamed:@"home"] //加载 png图片 在ios中获取一张图片只需要写图片名即可 不需要写后缀 默认都是加载.png的图片 但 ...
- 我的Android最佳实践之—— ImageView中图片拉伸显示
通过设置android:scaleType="fitXY"使得图片拉伸显示.补充:scaleType的属性有matrix(默认).center.centerCrop.centerI ...
- ios UIImage图片拉伸 resizableImageWithCapInsets:
常见的按钮添加和背景设置如下: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(80, 130, 160, 44)];[bu ...
随机推荐
- 一个简单的python程序
假设我们有这么一项任务:简单测试局域网中的电脑是否连通.这些电脑的ip范围从192.168.0.101到192.168.0.200. import subprocesscmd="cmd.ex ...
- JS手札
Node JS 关于JS调用 被调用:exports.cv=cv; cv为类,可以使用其方法cv.***: cv为函数名,可以使用其函数cv( , ): 调用: var cv=require(cv); ...
- c51跑马灯
ORG 0000HMOV 20H, #0FFHMOV 21H, #0FDHMOV 22H, #0FBHMOV 23H, #0F7HMOV 24H, #0EFHMOV 25H, #0DFHMOV 26H ...
- ghj
如果对同一个元素的定义有多种,以最接近(最小一级)的定义为最优先,例如有这么一段代码 Update: Lorem ipsum dolor set 在CSS文件中,你已经定义了元素p,又定义了一个cla ...
- asd
弹出输入提示框 :window.prompt(); 24. 指定当前显示链接的位置 :window.location.href="URL" 25. 取出窗体中的所有表单的数量 :d ...
- Hot code replace failed
今天在eclipses中 修改代码,保存时会出时不时出现Hot code replace failed 对话框,谷歌提示是在debug模式下保存修改源代码会出现此类问题.确实,刚刚在用debug功能, ...
- css技术
CSS是英语Cascading Style Sheets(层叠样式表单)的缩写,它是一种用来表现HTML或 XML 等文件式样的计算机语言. CSS 目前最新版本为CSS2,能够真正做到网页表现与内容 ...
- get_headers()函数
get_headers() 是PHP系统级函数,他返回一个包含有服务器响应一个 HTTP 请求所发送的标头的数组.如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息(可用来判断 ...
- jd-gui报错INTERNAL ERROR 解决办法
问题:我用dex2jar工具反编译了apk文件,但当我用jd-gui反编译前面操作获得的jar文件的时,能很完美地看到大部分类反编译后的代码,但有一部分类不能显示出来--constants类,仅仅显示 ...
- OpenCV MAT基本图像容器
参考博客: OpenCv中cv::Mat和IplImage,CvMat之间的转换 Mat - 基本图像容器 Mat类型较CvMat和IplImage有更强的矩阵运算能力,支持常见的矩阵运算(参照Mat ...