zoukankan      html  css  js  c++  java
  • 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  

    纸上得来终觉浅,绝知此事要躬行
  • 相关阅读:
    用Sql添加删除字段,判断字段是否存在的方法
    [转]SQL Server中获得EXEC后面的sql语句或者存储过程的返回值的方法
    sql日记(相关子查询,动态交叉表篇)
    一种迅速从datatable生成excel文件的方法
    系统设计说明书(架构、概要、详细)目录结构
    针对Web系统常用的功能测试方法浅析
    单元测试(UnitTest)入门
    文件操作概览
    C#仿QQ面板的简单实现
    用MD5和SHA1加密字符串
  • 原文地址:https://www.cnblogs.com/asheng/p/4404308.html
Copyright © 2011-2022 走看看