title: How to mask an UIimage with UIColor?
body: <p>I wish to mask an <code>UIimage</code> with <code>UIColor</code>. Refer to the code below. Its not working for me. <em>I am trying to mask light to mid-‐range brown colors in the image.</em></p>
  
  <blockquote>
    <p><code>ivMasking1</code> is source <code>Imageview</code>.</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>    UIGraphicsBeginImageContext(ivMasking1.frame.size);
      CGContextRef context = UIGraphicsGetCurrentContext();
      const CGFloat myMaskingColors[6] = {124, 255,  68, 222, 0, 165};
      CGImageRef myColorMaskedImage = CGImageCreateWithMaskingColors (ivMasking1.image.CGImage,
                                                           myMaskingColors);
      CGRect myContextRect = CGRectMake(0,0,50,50);
  
      CGContextDrawImage (context, myContextRect, myColorMaskedImage);
  
      ivMasking2 = [[UIImageView alloc] initWithImage:UIGraphicsGetImageFromCurrentImageContext()];
      ivMasking2.frame = CGRectMake(0 ,125, 300,200);
      ivMasking2.contentMode = UIViewContentModeScaleAspectFit;
      ivMasking2.backgroundColor = [UIColor redColor];
      [self.view addSubview:ivMasking2];
  </code></pre>
  
  <p>Thanks!
  P.S. : You may refer to the topic: <strong>Masking an Image with Color</strong> from <strong><a href="https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html" rel="nofollow">Quartz Programming Guide</a></strong></p>