UIImage

图片拉伸

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

// 加载原图
UIImage *image = [UIImage imageNamed:@"chat_send_nor"];

// 拉伸处理(说明需要保护的区域)
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(30, 30, 30, 30) resizingMode:UIImageResizingModeStretch];

// left
// top
// width
// height
// right = width - left - 1;
// bottom = height - top - 1;
// 根据以上公式计算,需要你给出左边保护多少,和上面保护多少
image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
文章作者: Ammar
文章链接: http://lizhaoloveit.cn/2014/04/03/UIImage/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Ammar's Blog
打赏
  • 微信
  • 支付宝

评论