title: Inverting colors on UIImageView
body: <p>I am trying to invert colors on UIImageView, but the problem is when I try to invert colors , the transparent area fills with white color :</p>
  
  <p><img src="https://i.stack.imgur.com/EeXcp.png" alt="enter image description here"></p>
  
  <p>only white areas should be inverted to black color , but the result is :</p>
  
  <p><img src="https://i.stack.imgur.com/D1gSX.png" alt="enter image description here"></p>
  
  <p>here is my codes  :</p>
  
  <pre><code>- (void)invertColorWithImage:(UIImageView*)image {
  
  
      UIGraphicsBeginImageContext(image.image.size);
      CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeCopy);
      [image.image drawInRect:CGRectMake(0, 0, image.image.size.width, image.image.size.height)];
      CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeDifference);
      CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);    
      CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, image.image.size.width, image.image.size.height));
      image.image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
  }
  </code></pre>
  
  <p>I chante this line to clear color but nothing changed :</p>
  
  <pre><code>CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),[UIColor whiteColor].CGColor);    
  </code></pre>