title: Mask Image to Round in iOS
body: <p>I know there are many questions about mask but answers for them didn't help me (just partly).</p>
  <p>I need to do my image round. I created <a href="http://goo.gl/6uqjO" rel="nofollow noreferrer">mask.png</a> and use it in code:</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);
  UIImage* maskedImage = [UIImage imageWithCGImage:masked];
  
  CGImageRelease(masked);
  CGImageRelease(mask);
  return maskedImage;
  }
  </code></pre>
  <p>Everything was great and everybody was happy. But when I start test this method at device I found that it isn't mask my image (in simulator everything working ok). How I can mask my image?</p>
  <p>P.S. Temporarily I seted view.layes.mask as layer with my mask. And this variant is working at the device. May be any way to save round from this layer?</p>