Tengo el siguiente código:dibujar CALayer en un CGContext
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CALayer *sublayer = [CALayer layer];
sublayer.backgroundColor = [UIColor orangeColor].CGColor;
sublayer.cornerRadius = 20.0;
sublayer.frame = CGRectMake(20, 0, 300, 20);
[sublayer setNeedsDisplay];
[sublayer drawInContext:context];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
Pero cuando veo el retorno newImage, sólo hay una imagen vacía. Cuando cambio drawInContext para renderInContext, entonces obtuve la subcapa anterior, pero parece que el sistema de coordenadas está desordenado.
¿Alguna idea de por qué drawInContext en lo anterior no funcionó?