UIImage *image2 = [UIImage imageNamed:imgName];
CGFloat top = ; // 顶端盖高度
CGFloat bottom = ; // 底端盖高度
CGFloat left = ; // 左端盖宽度
CGFloat right = ; // 右端盖宽度
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
image2 = [image2 resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
// UIImageResizingModeStretch:拉伸模式,通过拉伸UIEdgeInsets指定的矩形区域来填充图片
// UIImageResizingModeTile:平铺模式,通过重复显示UIEdgeInsets指定的矩形区域来填充图片
// [btn setImage:image2 forState:UIControlStateNormal];//[UIImage imageNamed:imgName]
[btn setBackgroundImage:image2 forState:UIControlStateNormal];