UIView *yourView = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 220,220)];
[self.view addSubview:yourView];
UIImage *image = [UIImage imageNamed:@"018.png"];
yourView.layer.contents = (__bridge id)image.CGImage;
// 设置显示的图片范围
// yourView.layer.contentsCenter = CGRectMake(0.25,0.25,0.5,0.5);//四个值在0-1之间,对应的为x,y,width,height。
网友评论