先把MJ部落格詳細位址放這
http://blog.csdn.net/q199109106q/article/details/8615661
然後是我自己實踐的總結,在此mark,友善調用;
UIImage * image = [UIImage imageNamed:@"logo40.png"];
//原圖尺寸為40×40,這麼整能讓圖檔從中心點拉伸
CGFloat top = 20; // 頂端蓋高度
CGFloat bottom = 20 ; // 底端蓋高度
CGFloat left = 20; // 左端蓋寬度
CGFloat right = 20; // 右端蓋寬度
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
// 指定為拉伸模式,伸縮後重新指派
image = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
UIImageView * imageView = [[UIImageView alloc] initWithImage:image];
[imageView setFrame:self.view.bounds];
[self.view addSubview:imageView];