0

I want to split a NSString into several lines with different width, I find this method [NSString sizeWithFont:forWidth:lineBreakMode:] in the doc,but it doesn't provide the position where the linebreak take place. Is there any method in IOS that works like the following in Symbian:

class CFont :
TextCount()
IMPORT_C TInt TextCount(const TDesC &aText, TInt aWidthInPixels) const;

Description Gets how much of the specified descriptor can be displayed in this font without exceeding the specified width.

Note:

This function does not display any of the descriptor itself - it is used before display, to test whether the whole descriptor can be displayed.

Parameters:

const TDesC &aText The descriptor. TInt aWidthInPixels The available width for character display.

Return value:

TInt The number of characters which will be able to be displayed without exceeding the specified width. The count starts from the beginning of the descriptor.

TextCount()
IMPORT_C TInt TextCount(const TDesC &aText, TInt aWidthInPixels) const;

Description: Gets how much of the specified descriptor can be displayed in this font without exceeding the specified width.

Note:

This function does not display any of the descriptor itself - it is used before display, to test whether the whole descriptor can be displayed.

Parameters:

const TDesC &aText The descriptor.

TInt aWidthInPixels The available width for character display.

Return value:

TInt The number of characters which will be able to be displayed without exceeding the specified width. The count starts from the beginning of the descriptor.

thelaws
  • 7,991
  • 6
  • 35
  • 54
pnchen
  • 1
  • 1

1 Answers1

0

I think that

sizeWithFont:constrainedToSize:lineBreakMode:

maybe what you need. see What is -[NSString sizeWithFont:forWidth:lineBreakMode:] good for?

Community
  • 1
  • 1
Ants
  • 1,338
  • 16
  • 27
  • beacuse I want to get the string each line,but these method only provide the string’s bounding box. – pnchen Dec 10 '10 at 05:40