开发者

NSString where does the linebreak go

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.


I think that

sizeWithFont:constrainedToSize:lineBreakMode:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜