Stretching an UIImage while preserving the corners




 original image


 result














myImageView.image = [myImageView.image resizableImageWithCapInsets:UIEdgeInsetsMake(20.f, 12.f, 19.f, 19.f)];


For lower iOS version, use 

[UIImage stretchableImageWithLeftCapWidth:15 topCapHeight:13];