UIImage * image = [UIImage imageNamed:@"main_bk"];
// 設(shè)置端蓋的值
CGFloat top = 10;
CGFloat left = 10;
CGFloat bottom = 10;
CGFloat right = 10;
// 設(shè)置端蓋的值
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(top, left, bottom, right);
// 設(shè)置拉伸的模式
UIImageResizingMode mode = UIImageResizingModeStretch;
// 拉伸圖片
UIImage *newImage = [image resizableImageWithCapInsets:edgeInsets resizingMode:mode];
_bgImgView.image = newImage;