问题是:
使用iPhone7时,
我从CGContextRef
获得UIView
,然后 bitsPerPixel 64 。因为我的 .a 只适用于bitsPerPixel为32的传统RGB色彩空间位图缓冲区,
有人知道如何将色彩空间宽广的CGContextRef
转换为tranditional CGContextRef
,就像在iPhone6上一样吗?
答案 0 :(得分:0)
解决方案如下:
#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
将上面的代码添加到您将要绘制的视图中,然后从视图中获取的CGContextRef是传统的,就像在iPhone6上一样