UIImage *image = [UIImage imageNamed:@"playing"];
_layerView.layer.contents = (__bridge id)image.CGImage;
//同样可以设置显示的图片范围
//不过此处略有不同,这里的四个值均为0-1之间;对应的依然是写x,y,widt,height
_layerView.layer.contentsCenter = CGRectMake(0.25, 0.25, 0.5, 0.5);
UIImage *image = [UIImage imageNamed:@"playing"];
_layerView.layer.contents = (__bridge id)image.CGImage;
//同样可以设置显示的图片范围
//不过此处略有不同,这里的四个值均为0-1之间;对应的依然是写x,y,widt,height
_layerView.layer.contentsCenter = CGRectMake(0.25, 0.25, 0.5, 0.5);
本文标题:ios. 给UIView设置图片
本文链接:https://www.haomeiwen.com/subject/jhfpirtx.html
网友评论