title: How to check pixel color of a UIView or a UIImage?
body: <p>I am trying to check if an entire UIView is filled with one color. I managed to get a screenshot of the UIView using the following block of code:</p>
  
  <pre><code>UIImage *image = [self imageFromView];
  NSFileManager *fileManager = [NSFileManager defaultManager];
  NSData *myImageData = UIImagePNGRepresentation(image);
  [fileManager createFileAtPath:@"/Users/{username}/Desktop/myimage.png" contents:myImageData attributes:nil];
  [imageData writeToFile:@"/testImage.jpg" atomically:YES];
  </code></pre>
  
  <p>The method implementation for imageFromView is the following:</p>
  
  <pre><code>- (UIImage*)imageFromView{  
  UIImage *bitmapImage;
  UIGraphicsBeginImageContext(self.bounds.size);
  [self.layer renderInContext:UIGraphicsGetCurrentContext()];
  bitmapImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return bitmapImage; 
  }
  </code></pre>
  
  <p>So from what I understand, I now have a bitmap image of the UIView. How do I access each pixel of the UIImage and check to verify it is in fact one color (i.e. UIColor blackColor)?</p>