UIImage *backgroundImage = [UIImage imageNamed:@"block_background.png”];
backgroundImage = [backgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(top, left, bottom, right)];
拉伸的是中间被围出的矩形区域:UIEdgeInsetsMake(top, left, bottom, right),分别是距离上边,左边,下边和右边的距离
如果不需要横向或纵向拉伸,该矩形可以理解成“一条线”,如
backgroundImage = [backgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(15, 320, 14, 0)];//横向不需要拉伸
(假定320为图片横向尺寸)