title: How to create own mask in ios
body: <p><img src="https://i.stack.imgur.com/3Yi31.png" alt="enter image description here"></p>
  
  <p><a href="https://stackoverflow.com/questions/5757386/how-to-mask-an-uiimageview">Duplicate</a> </p>
  
  <p>so don't negative my reputation. </p>
  
  <p>My mask image is : 
  <img src="https://i.stack.imgur.com/NuHA7.png" alt="enter image description here"></p>
  
  <p>My output is : <img src="https://i.stack.imgur.com/WwlHc.png" alt="enter image description here"></p>
  
  <pre><code>- (UIImage*)maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
  
      CGImageRef maskRef = maskImage.CGImage;
  
      CGImageRef mask = CGImageMaskCreate(
                                          CGImageGetWidth(maskRef),
                                          CGImageGetHeight(maskRef),
                                          CGImageGetBitsPerComponent(maskRef),
                                          CGImageGetBitsPerPixel(maskRef),
                                          CGImageGetBytesPerRow(maskRef),
                                          CGImageGetDataProvider(maskRef), NULL, false
                                          );
  
      CGImageRef masked = CGImageCreateWithMask(image.CGImage, mask);
      CGImageRelease(mask);
      return [UIImage imageWithCGImage:masked];
  }
  </code></pre>
  
  <p>So how to create my own mask image?</p>
  
  <p>Thanks...</p>