创建一个扩展 UIImage的类
#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
调用
[self.textView setBackgroundImage:[UIImage resizableImage:@"chat_send_nor"] forState:UIControlStateNormal];