Search code examples
iphonesdkios4word-wrapcgpoint

Multiline text (wordwrap) with drawAtPoint?


is there a way to draw multiline text with drawAtPoint? I have tried UILineBreakModeWordWrap but doesnt seem to be working?

How would you convert this code to a working multiline text??

point = CGPointMake(boundsX, 50);
[self.heading drawAtPoint:point forWidth:labelWidth withFont:mainFont minFontSize:12.0 actualFontSize:NULL lineBreakMode:UILineBreakModeWordWrap baselineAdjustment:UIBaselineAdjustmentAlignBaselines];

Thank you!


Solution

  • drawAtPoint: doesn't support multiline text. You can use drawInRect: method instead.

    Edit: (Copying @George Asda's comment below to here)

    [self.heading drawInRect:(contentRect) withFont:mainFont    
            lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];