您的位置:首页 > 产品设计 > UI/UE

resizableImageWithCapInsets 图片拉伸

2016-04-15 09:54 573 查看
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(50, 100, 300, 300)];
CGSize size = [UIImage imageNamed:@"test"].size;
NSLog(@"---- width:%.0f - height:%.0f",size.width,size.height);
imgView.image = [[UIImage imageNamed:@"test"] resizableImageWithCapInsets:UIEdgeInsetsMake(100, 100, 100, 100) resizingMode:UIImageResizingModeTile];
[self.view addSubview:imgView];
图片size    ---- width:248 - height:259
拉伸后的显示结果



UIEdgeInsetsMake(100,
100, 100,
100) 是相对原图来讲的 (width:248 - height:259),相对原图的这个范围内的内容被拉伸。边缘受到保护。

UIImageResizingModeStretch:拉伸模式,通过拉伸UIEdgeInsets指定的矩形区域来填充图片

UIImageResizingModeTile:平铺模式,通过重复显示UIEdgeInsets指定的矩形区域来填充图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息