有谁知道为什么CGContextDrawImage会把我的形象颠倒过来?我从我的应用程序加载图像:
UIImage *image = [UIImage imageNamed:@"testImage.png"];
Run Code Online (Sandbox Code Playgroud)
然后简单地要求核心图形将其绘制到我的上下文中:
CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage);
Run Code Online (Sandbox Code Playgroud)
它呈现在正确的位置和尺寸,但图像是颠倒的.我一定错过了一些非常明显的东西吗?
试着理解为什么我用CGContextShowTextAtPoint获得低质量的绘图?见附图:

字母"W"是在CALayer上使用CGContextShowTextAtPoint绘制的,看起来非常像素化.它旁边的按钮是一个标准按钮,按预期看起来很高.我想让文字绘图成为高分辨率.

在我的iOS应用程序中,我正在尝试使用CoreGraphics绘制曲线.绘图本身工作正常,但在视网膜显示器上,图像使用相同的分辨率绘制,并且不会使像素加倍.结果是像素化图像.
我正在使用以下功能绘图:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.canvasView];
UIGraphicsBeginImageContext(self.canvasView.frame.size);
[canvasView.image drawInRect:self.canvasView.frame];
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(ctx, YES);
CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextSetLineWidth(ctx, 5.0);
CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 1.0);
CGContextBeginPath(ctx);
CGContextMoveToPoint(ctx, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(ctx, currentPoint.x, currentPoint.y);
CGContextStrokePath(ctx);
canvasView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
// some code omitted from this example
}
Run Code Online (Sandbox Code Playgroud)
我发现的建议是使用scaleFactor属性或CGContextSetShouldAntialias()函数,但到目前为止这些都没有帮助.(虽然我可能不恰当地使用它们.)
任何帮助将不胜感激.
我有一个UIView,它从drawRect:rect中画一个圆圈.在Retina显示屏上阅读Apple dev信息后,似乎使用Core Graphics意味着图纸会自动利用更高的分辨率.然而,与徽章图标中的类似圆圈相比,这个简单的圆圈看起来相当粗糙.显然我正在将它与具有光泽和阴影的东西进行比较,但我认为很明显我的画面并没有被画出来.我尝试拍摄苹果图标徽章和我的圈子的屏幕截图,他们在我的Mac上看起来一样 - 不过在看电话的时候差别很明显.这里有什么简单的东西吗?
这是我在drawRect:rect中使用的绘图代码
UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect:
CGRectMake(0, 0, 22, 22)];
[[UIColor whiteColor] setStroke];
[[UIColor redColor] setFill];
CGContextRef aRef = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(aRef, 10, 10);
aPath.lineWidth = 3;
[aPath fill];
[aPath stroke];
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助,Rob