iPhone – How to draw multi-line text using DrawatPoint?

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:UILineBreakModeTaillineAdjustment:UILineBreakModeTaillineAdjustment
baseline ];

How do I 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];

-drawAtPoint’s document: withFont: …Said “This method does not perform any line breaks during drawing”. If you use -drawInRect:withFont: instead of -drawAtPoint:withFont:…, then it will draw multiple lines. You can also use -sizeWithFont:constrainedToSize: to determine the size .

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 do I 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];

-drawAtPoint’s documentation: withFont: … says “This method does not perform any line breaks during drawing “. If you use -drawInRect:withFont: instead of -drawAtPoint:withFont:…, then it will draw multiple lines. You can also use -sizeWithFont:constrainedToSize: to determine the size.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1078 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.