UIImage *img = [UIImage imageNamed:@"hehe"];
CGFloat top = 166; //顶端盖高度
CGFloat bottom = 166 ; //底端盖高度
CGFloat left = 10; //左端盖宽度
CGFloat right = 10; //右端盖宽度
UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
img = [img resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
UIImageView *view = [[UIImageView alloc] initWithImage:img];
view.frame = CGRectMake(50, 100, 150, 600);
[self.view addSubview:view];
hehe原图 图片分辨率:1500 * 1500
内容 9宫格 等宽等高
设置拉伸后 这样保证上下不拉伸 只拉伸中间部分
网友评论