图片保真处理

方式一:

//直接拉伸全局图片:造成图片严重失真
    UIImage *image = [UIImage imageNamed:@"chat_send_nor"];
直接全部拉伸

方式二:iOS 6引入

局部保真,内部填充
//2.(1)保护图片(上,左,下,右)部分宽度后【用剩余部分】平铺式(ModeTile,默认)填充;
    image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 35, 30, 40) resizingMode:UIImageResizingModeTile];
四周保真,内部平铺式填充
//2.(2)保护图片(上,左,下,右)部分宽度后【用剩余部分】拉伸式(ModeStretch)填充;
    image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 35, 30, 40) resizingMode:UIImageResizingModeStretch];
四周保真,内部拉伸式填充

方式三:

    //3.只给出(左,上)参数,右下参数系统自动计算。【用剩余部分】直接拉伸式(ModeStretch)填充,很古老的一种方式。
    image = [image stretchableImageWithLeftCapWidth:35 topCapHeight:30];
1 X 1式填充

系统计算(右,下)参数的公式:
right: Width - left -1;
bottom: Height - top - 1;
剩余部分为:
width = Width - left - right = 1;
height = Height - top - bottom = 1
所以,才被称为是 X 1式填充。

方式四:

通过Assets直接可视化设置

该方式实际上是方法二,但是为1 X 1式填充方式。

你可能感兴趣的:(图片保真处理)