实现图片拉伸有三种方式.
1.直接修改图片资源
2.通过图片框可直接修改stretching
images/loading.gif' data-original="http://images2015.cnblogs.com/blog/927314/201607/927314-20160712094245154-985726997.png" />
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];
}
原标题:图片拉伸的封装
关键词:图片