I am custom drawing some text:
point = CGPointMake(77, 5);
[[message valueForKey:@"user_login"] drawAtPoint:point forWidth:200
withFont:mainFont
minFontSize:MIN_MAIN_FONT_SIZE
actualFontSize:NULL
lineBreakMode:UILineBreakModeTailTruncation
baselineAdjustment:UIBaselineAdjustmentAlignBaselines];
How can I make it draw 5 lines? Equivalent to:
rect = CGRectMake(77, 25, 238, 68);
bodyLabel = [[UILabel alloc] initWithFrame:rect];
bodyLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
bodyLabel.numberOfLines = 5;
bodyLabel.lineBreakMode = UILineBreakModeWordWrap;
bodyLabel.textColor = [UIColor blackColor];
[self.contentView addSubview: bodyLabel];
The documentation for
-drawAtPoint:withFont:...says “This method does not perform any line wrapping during drawing.” If you use-drawInRect:withFont:instead of-drawAtPoint:withFont:..., then it will draw multiple lines. You can also use-sizeWithFont:constrainedToSize:to figure out what the size will be.