rendering a new line in a string (\n) with drawRect

Posted by Mrwolfy on Stack Overflow See other posts from Stack Overflow or by Mrwolfy
Published on 2012-09-02T09:35:29Z Indexed on 2012/09/02 9:37 UTC
Read the original article Hit count: 215

Filed under:
|
|
|

I am trying to render a string with a new line (line break \n), using drawRect.

The code below renders the my string as a single line, with no line break, even though I am using the \n character. See the second to last line.

UIFont *font =  [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:fontSize];
CGPoint point = CGPointMake(0,0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
CGContextSetLineWidth(context, 4.0);
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
CGContextSaveGState(context);
[@"test \n test" drawAtPoint:point withFont:font];

CGContextRestoreGState(context);

© Stack Overflow or respective owner

Related posts about ios

Related posts about xcode