标签:
---------- UIImage+CZHelp.h ----------
#import <UIKit/UIKit.h>
@interface UIImage (CZHelp)
+ (UIImage *)resizedImageNamed:(NSString *)name leftScale:(CGFloat)leftScale topScale:(CGFloat)topScale;
+ (UIImage *)resizedImageNamed:(NSString *)name;
@end
---------- UIImage+CZHelp.m ----------
#import "UIImage+CZHelp.h"
@implementation UIImage (CZHelp)
+ (UIImage *)resizedImageNamed:(NSString *)name
{
return [self resizedImageNamed:name leftScale:0.5 topScale:0.5];
}
+ (UIImage *)resizedImageNamed:(NSString *)name leftScale:(CGFloat)leftScale topScale:(CGFloat)topScale
{
UIImage *image = [UIImage imageNamed:name];
return [image stretchableImageWithLeftCapWidth:image.size.width * leftScale topCapHeight:image.size.height * topScale];
}
@end
标签:
原文地址:http://www.cnblogs.com/lixiang2015/p/4719815.html