title: Fastest way to get pixel/point color of screen content on iOS
body: <p>I am trying to get the color of pixels/points (doesn't matter for my use case) of the current screen content in iOS. So, for example, I want to get the color of each pixel from screen coordinates <code>0, 0</code> to <code>10, 10</code>. Additionally, the operation should be as fast as possible, since I will do it at regular intervals as a Timer. The timer should run multiple times a second, but it doesn't have to be 25fps.</p>
  
  <p>Acceptable solutions:
  Anything that returns the current color of a pixel or point on screen at a given position, doesn't produce noticable UI lag and doesn't turn my app into a battery hog. The result might be a CGImage, UIImage, buffer array, I don't really care. I also don't care if the solution uses additional Apple frameworks, such as OpenGL or Metal.<br>
  It is also acceptable if the solution does not capture system-UI, like the statusbar. Capturing the content of my app is sufficient.</p>
  
  <p><strong>Things I tried so far:</strong></p>
  
  <ul>
  <li>Using <code>UIWindow</code>s <code>drawHierarchy(in:afterScreenUpdates:)</code>. This method turns out to be way too slow. On my iPad Pro, it took 0.25s which causes noticable UI lag.</li>
  <li>Using <code>CALayer</code>s <code>render(in:)</code>, but this method does not render <code>UIVisualEffectView</code>s, which I require. Also, while faster than drawHierarchy, I measured it at about 0.04s, which still causes noticable lag in the UI.</li>
  <li>Use OpenGL, as for example described <a href="https://stackoverflow.com/a/2200778/1421550">here</a>. I don't know anything about OpenGL, so I might be using this wrong, but I never got it to return anything other than a black image.</li>
  </ul>