2

Am having the mask image and the normal image i want to do the exact clipping mask effect and want to set that image to the UIImageView.

enter image description here

In this PIP Camera app they did this

https://itunes.apple.com/in/app/hua-zhong-hua-xiang-ji-nice/id521922264?mt=8

And i tried this

How to Mask an UIImageView exactly what they suggest but no luck

Could anyone here give an idea of how we do that?

Community
  • 1
  • 1
Vignesh
  • 592
  • 6
  • 25
  • Check out ImageMagicks : http://www.imagemagick.org/Usage/masking/ – Mrug Apr 12 '16 at 10:41
  • And another simple way is to use layer.mask property. But in that case you will need Masking image having Black and White tones. – Mrug Apr 12 '16 at 10:42
  • I tried the layer mask property // CALayer *mask = [CALayer layer]; mask.contents = (id)[[UIImage imageNamed:@"mask.png"] CGImage]; mask.frame = CGRectMake(0, 0, 200, 200); _BackgroundImage.layer.mask = mask; _BackgroundImage.layer.masksToBounds = YES; self.BackgroundImage.layer.mask = mask; [_BackgroundImage.layer setMasksToBounds:YES]; – Vignesh Apr 12 '16 at 11:00
  • It's not worked for me – Vignesh Apr 12 '16 at 11:01
  • CALayer *maskLayer = [CALayer layer]; UIImage *mask = [UIImage imageNamed:@"m0_mask.png"]; maskLayer.contents = (id)mask.CGImage; maskLayer.contentsGravity = kCAGravityCenter; maskLayer.frame = self.BackgroundImage.bounds; _BackgroundImage.image = [UIImage imageNamed:@"12.png"]; _BackgroundImage.layer.mask = maskLayer; [self.view addSubview:_BackgroundImage]; – Vignesh Apr 12 '16 at 11:31
  • Thanks man its working – Vignesh Apr 12 '16 at 11:32
  • @Vignesh in my case it doesn't make a proper image. The selected image(Lady image) is replaced with mask image. – Pramod Tapaniya Feb 08 '17 at 09:15
  • Can you please show your output – Vignesh Feb 08 '17 at 10:59

0 Answers0