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

UIImageView 的 layer.mask

2016-11-16 10:51 176 查看
三军未到,粮草先行,先看看效果,有微信图片的效果啊 



接着就是干货了 。。 

代码奉上

UIImageView *img1=[[UIImageView alloc] init];
img1.frame=CGRectMake(20, 20, 100, 50);
img1.image=[UIImage imageNamed:@"test1"];
[self.view addSubview:img1];

UIImageView *img2=[[UIImageView alloc] init];
img2.frame=CGRectMake(20, 90, 100, 150);
img2.image=[UIImage imageNamed:@"test2"];
[self.view addSubview:img2];

UIImageView *imageViewMask1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test1"]];
imageViewMask1.frame = CGRectMake(0, 0,100, 50);

UIImageView *photoImage1=[[UIImageView alloc] init];
photoImage1.frame=CGRectMake(160, 90, 100, 150);
photoImage1.image=[UIImage imageNamed:@"test2"];
photoImage1.layer.mask = imageViewMask1.layer;
[self.view addSubview:photoImage1];

UIImageView *image3=[[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"wechatback1"] stretchableImageWithLeftCapWidth:10 topCapHeight:25]];
image3.frame=CGRectMake(10, 300, 100, 150);
[self.view addSubview:image3];

UIImageView *imageViewMask = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"wechatback1"] stretchableImageWithLeftCapWidth:10 topCapHeight:25]];
imageViewMask.frame = CGRectMake(0, 0, 100, 150);

UIImageView *photoImage=[[UIImageView alloc] init];
photoImage.frame=CGRectMake(170, 300,  100, 150);
photoImage.image=[UIImage imageNamed:@"test2"];
photoImage.layer.mask = imageViewMask.layer;
[self.view addSubview:photoImage];






内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios layer.mask