[英]How to use renderInContext: with CGBitmapContextCreate and Retina?
我已經手動創建了CGBitmapContext:
bitmapContext = CGBitmapContextCreate( myImageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );
並為其繪制一層:
[self.myView.layer renderInContext:bitmapContext];
但是,在Retina上,我的圖層僅渲染原始大小的一半。
在UIView
上設置contentScaleFactor
屬性不會更改任何內容。
什么是正確的方法?
當然,在我問問題的那一刻,答案就出現了。 只需執行以下操作:
float scale = self.myView.contentScaleFactor;
CGContextScaleCTM(context, scale, scale);
[self.myView.layer renderInContext:context];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.