CoreGraphics テキスト描画

テキストを描画するには, CGContextShowTextAtPoint
を使います。
CGContextShowTextAtPoint(context, x, y, “”, length); // Text is CString char *, char[]

文字列には, CString, char *, char[] などC系文字列を利用します。最後の引数部分は文字列の長さをいれます(length)。

- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context,
1.0, 0.0, 0.0, 1.0);
CGContextSetRGBStrokeColor(context,
0.5, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 2.0);

CGContextSelectFont(context, "Arial Bold",
36, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context,
kCGTextFillStroke);

CGAffineTransform affine = CGAffineTransformMake
(1.0, 0.0, 0.0, -1.0, 0.0, 0.0);
CGContextSetTextMatrix(context, affine);

CGContextShowTextAtPoint(context,
50.0, 50.0, "Love iPhone", 11);
}

drawtext

参考
Libro.