rendering a new line in a string (\n) with drawRect
- by Mrwolfy
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);