wide color on iPhone7

216 views Asked by At

The Question is :

When working on iPhone7,

I get CGContextRef from UIView, then the bitsPerPixel is 64. Cause my .a can only work with traditional RGB colorspace bitmap buffer whose bitsPerPixel is 32,

Could someone know how to convert CGContextRef whose colorspace is wide color to tranditional CGContextRef just like on iPhone6 ?

1

There are 1 answers

0
CoderHunter On

The Solution is below:

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_9_3
-(void) layerWillDraw:(CALayer *)layer 
{
    if( [[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0 )
    {
        NSString* format = layer.contentsFormat;
        if( ![format isEqualToString:kCAContentsFormatRGBA8Uint]  )
            layer.contentsFormat = kCAContentsFormatRGBA8Uint;
    }
}
#endif

add the code above to the view which you will draw on, then the CGContextRef got from the view is traditional, just as on iPhone6