标签:io ar os sp on 文件 bs as size
//头文件
#import <UIKit/UIKit.h> @interface UIImage (Extension) //传入图片的name.然后返回一个拉伸后的图片(新图片) +(UIImage *)resizableImage:(NSString *)name; @end
//实现
#import "UIImage+Extension.h" @implementation UIImage (Extension) //用来拉伸图片,图片四周样式不变 +(UIImage *)resizableImage:(NSString *)name{ UIImage *normal = [UIImage imageNamed:name]; CGFloat w = normal.size.width * 0.5; CGFloat h = normal.size.height * 0.5; //核心方法,相当于改图片只拉伸内部,外边不变. return [normal resizableImageWithCapInsets:UIEdgeInsetsMake(h, w, h, w)]; } @end
标签:io ar os sp on 文件 bs as size
原文地址:http://my.oschina.net/u/2285956/blog/355844