例如一张图片
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
UIImageView *ImgVW = [[UIImageView alloc]initWithFrame:CGRectMake(20, 64, self.view.frame.size.width-40, 250)];
UIImage *myimage = [UIImage imageNamed:@"balloon_file_right_blue@2x.png"];
CGFloat top = 20; // 顶端盖高度
CGFloat bottom = 20; // 底端盖高度
CGFloat left = 10; // 左端盖宽度
CGFloat right = 10; // 右端盖宽度
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
// 指定为拉伸模式,伸缩后重新赋值
myimage = [myimage resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
// myimage = [myimage resizableImageWithCapInsets:insets];
ImgVW.image = myimage;
[self.view addSubview:ImgVW];
}