图片拉伸的打包

图片拉伸的封装
 
实现图片拉伸有三种方式.
1.直接修改图片资源
2.通过图片框可直接修改stretching图片拉伸的打包

 

3.就是通过代码的实现 
// 可以把NSString 的参数 改成NSArray 数组存放参数 (就是可以修改多个)
+ (UIImage *)stretchImageWith:(NSString *)imageString{
 
//实例化Image对象
UIImage *otherImage = [UIImage imageNamed:imageString];
 
//计算图片的中心点
CGFloat halfWidth = otherImage.size.width /2;
CGFloat halfHeight = otherImage.size.height / 2;
 
//对图片进行拉伸
return [otherImage resizableImageWithCapInsets:UIEdgeInsetsMake(halfHeight, halfWidth, halfHeight, halfWidth) resizingMode:UIImageResizingModeStretch];
 }