When I use drawInRect, it doesn’t recognize a newline and just drops everything after the screen. The view looks like:
First
But I expect it to look like:
First
Second
Here is the code:
periodText = @"First\nSecond";
periodStringSize = [periodText sizeWithFont:font];
periodStringRect = CGRectMake(aPeriod.origin.x+boxWidth/2-periodStringSize.width/2, aPeriod.origin.y, periodStringSize.width, periodStringSize.height);
[periodFontColor set];
[periodText drawInRect:periodStringRect withFont:periodFont];
Is there something I am doing wrong? The code works perfectly fine for strings without newlines.
Make sure your
periodStringRectis tall enough to display two lines.