在游戏中,经常会碰到九宫格的可拉伸图片,在ios开发中也可以使用,比如截取一部分拉伸,其他不变
3042303524.png
UIImage *img = [UIImage imageNamed:@"popup"]; img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 55) resizingMode:UIImageResizingModeStretch]; self.resizableImgView.image = img;
如果是平铺
7.png可这么实现
UIImage *img = [UIImage imageNamed:@"about"]; img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(0, 11.5, 0, 11) resizingMode:UIImageResizingModeTile]; self.resizableImgView.image = img;
网友评论