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
网友评论