Search code examples
iosswiftiphone

How to set pure red pixel full screen on iPhone OLED


I am studying the pixel arrangement of the iPhone OLED screen. I use the code:

for (int i = 0; i < height; i++)
{
    for (int j = 0; j < width; j++)
    {
        data[(i*width + j)*4] = (Byte) (255) ;
        data[(i*width + j)*4+1] = (Byte) (0) ;     
        data[(i*width + j)*4+2] = (Byte) (0) ;  
        data[(i*width + j)*4+3] = (Byte)255;
    }
 } 

in the viewController, when setting the iPhone X full screen to red, the screen pixels of the iPhone X seen with the microscope is not all red pixels, and green pixels can also be seen first.

What I want to achieve is that when setting to pure red, the pixels of the iPhone X only display red pixels, and green pixels or blue pixels cannot be displayed.
How can I solve this problem?

enter image description here


Solution

  • Try with system color:

    view.backgroundColor = UIColor.systemRed 
    

    iOS offers a range of system colors that automatically adapt to vibrancy and changes in accessibility settings like Increase Contrast and Reduce Transparency. https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/