CGContext 描画メソッドの代わりに drawInRect を使用することについて、この Web サイトでいくつかの投稿を読みました。それはまだそれを逆さまに描きますか?drawInRect を使用すると、座標系が左上から始まるように右向きに印刷されると思いましたか?
-(void) drawImage:(UIImage*) image atX:(float) x andY:(float) y withWidth:(float) width andHeight:(float) height onContext:(CGContextRef) context{
UIGraphicsPushContext(context);
[image drawInRect:CGRectMake(x, size.height-y-height, width, height)];
UIGraphicsPopContext();
}
私がやっていることに注意size.height-y-height
してください。そうしないと、期待した場所に移動しません(drawInRect
左上の座標系を使用すると仮定します)。上記のコードでは正しい場所にレンダリングされますが、上下逆になっています。ヘルプ!!!!!!
アップデート
以下の回答のおかげで、これが作業方法です
-(void) drawImage:(UIImage*) image atX:(float) x andY:(float) y withWidth:(float) width andHeight:(float) height onContext:(CGContextRef) context{
UIGraphicsPushContext(context);
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0, size.height);
CGContextScaleCTM(context, 1.0, -1.0);
[image drawInRect:CGRectMake(x, y, width, height)];
CGContextRestoreGState(context);
UIGraphicsPopContext();
}