//如果是UIImageView,可以在xib中设置Stretching属性,x,y设为0.5,width,height设为0,就可以拉伸图片,解决图片过小而产生四周模糊的效果,如果是UIbutton,只能通过代码实现
//先把image拉伸后在赋给UIButton,拉伸图片有两个方法
UIImage *image = [UIImage imageNamed:@"RedButton"];
[_butt setBackgroundImage:image forState:UIControlStateNormal];
//1.这种方式只需要两个参数,以中心点向左,向上1px向外拉伸
image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
//这种方法需要四个参数,一般用第一种就可以
//image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.height * 0.5, image.size.width * 0.5, image.size.height * 0.5, image.size.width * 0.5 )];
[_butt2 setBackgroundImage:image forState:UIControlStateNormal];