2

当我UIImage* image使用下面的代码在 UIView 上绘图时,图像是水平镜像的。就是这样,如果我画4,它就是这样画的替代文字..

CGRect rect = CGRectMake(x, y, imageWidth, imageHeight);
CGContextDrawImage((CGContextRef) g, rect, ((UIImage*)image).CGImage);

那就是问题所在???我做错了吗???或者如果有人知道如何解决它,请告诉我。我非常感谢提前。

感谢一个loooooooooot。

4

2 回答 2

5

参见:CGContextDrawImage 在传递 UIImage.CGImage 时将图像倒置

使用[image drawInRect:rect]而不是CGContextDrawImage.

于 2010-11-18T22:53:15.990 回答
3

您可以使用正确的方式转动图片

CGAffineTransform transform =CGAffineTransformMakeTranslation(0.0, height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
CGContextConcatCTM(context, transform);

//draw image in the context
CGContextDrawImage(context, rect, ((UIImage*)image).CGImage);

使用 [image drawInRect:rect] 使用默认上下文,即屏幕,你不能给它你当前的上下文,例如,如果你想把它作为按钮 ima 的一部分

于 2013-04-25T12:24:53.750 回答