我正在通过以下方式在核心图形中绘制文本
- (void)drawRect:(CGRect)rect {
CGContextTranslateCTM(context, 20, 150);
CGContextScaleCTM(context, 1, 1);
// Draw the text using the MyDrawText function
myDrawText(context, viewBounds);
}
void myDrawText (CGContextRef myContext, CGRect contextRect)
{
CGFloat w, h;
w = contextRect.size.width;
h = contextRect.size.height;
CGAffineTransform myTextTransform;
CGContextSelectFont (myContext,
"Helvetica-Bold",
h/12,
kCGEncodingMacRoman);
CGContextSetCharacterSpacing (myContext, .5);
CGContextSetTextDrawingMode (myContext, kCGTextFill);
CGContextSetRGBFillColor (myContext, 1, 1, 1, 1);
myTextTransform = CGAffineTransformMakeRotation (0);
CGContextSetTextMatrix (myContext, myTextTransform);
CGContextShowTextAtPoint (myContext, 115, 0, "Successful", 10);
}
运行它后,我得到的文本是上下颠倒的,如下所示
为什么绘图后文字是上下颠倒的
请就这个问题给我建议。