С кодом ниже, нарисованный слой CGContextDrawImage () имеет более низкое качество, чем исходный отображаемый слой.Некоторые строки на изображении совмещены.
Вот мой код
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSaveGState(ctx);
UIGraphicsBeginImageContext(layer.bounds.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(c, YES);
CGContextSetAllowsAntialiasing(c, YES);
CGContextSetInterpolationQuality(c, kCGInterpolationHigh);
[self.view.layer renderInContext:c];
CGImageRef image = CGBitmapContextCreateImage(c);
UIGraphicsEndImageContext();
CGImageRef flipImage = CGImageCreateWithImageInRect(image, layer.bounds);
CGContextTranslateCTM(ctx, 0, layer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0f, -1.0f);
CGContextSetShouldAntialias(ctx, YES);
CGContextSetAllowsAntialiasing(ctx, YES);
CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
CGContextDrawImage(ctx, layer.bounds, flipImage);
CGContextRestoreGState(ctx);
LogMessage(@"drawLayer", 1, @"draw layer content");
}
Обновление 1
Слой, окрашенный в drawLayer:
, имеет другой размерс экрана.Я хочу разрезать экран на части, а затем применить к ним анимацию.
оригинальный слой:
нарисованный слой: