不变形拉伸图片分类

UIImage+Resizable.h


#import@interface UIImage (Resizable)

+ (UIImage *)resizableWithImageName:(NSString *)imageName;

@end



UIImage+Resizable.m


#import "UIImage+Resizable.h"

@implementation UIImage (Resizable)

+ (UIImage *)resizableWithImageName:(NSString *)imageName {

UIImage *image = [UIImage imageNamed:imageName];

CGFloat W = image.size.width * 0.5;

CGFloat H = image.size.height * 0.5;

return [image stretchableImageWithLeftCapWidth:W topCapHeight:H];

}

@end


你可能感兴趣的:(不变形拉伸图片分类)