iOS开发图片做遮罩层,遮罩里面还可以滚动的

#pragma mark -这里是实现了图片遮罩

picImageview=[[UIImageView alloc]init];

int a=3;

picImageview.frame=CGRectMake(0, 0, 180*a, 250*a);

UIImage * picImage =[UIImage imageNamed:@"1.png"];

picImageview.image=picImage;

UIScrollView *s=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 180, 250)];

s.backgroundColor=[UIColor redColor];

s.contentSize=CGSizeMake(180*a, 250*a);

[s addSubview:picImageview];

//遮罩层的图片

CALayer *maskLayer=[CALayer layer];

maskLayer.frame=CGRectMake(0, 0, 180, 250);;

UIImage * maskImage =[UIImage imageNamed:@"abc.png"];

maskLayer.contents=(__bridge id)maskImage.CGImage;

UIView *aaaa=[[UIView alloc]initWithFrame:CGRectMake(0, 80, 180, 250)];

aaaa.userInteractionEnabled=YES;

aaaa.layer.mask=maskLayer;

[aaaa addSubview:s];

[self.view addSubview:aaaa];

你可能感兴趣的:(iOS开发图片做遮罩层,遮罩里面还可以滚动的)