『IOS』lineBreakMode

来源:互联网 发布:双11 品类销售数据 编辑:程序博客网 时间:2024/04/27 05:04

You need to use NSLineBreakByWordWrapping in ios6

For your code try this:

NSString *string = @"bla"; CGSize s = [string sizeWithFont:[UIFont systemFontOfSize:20] constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, CGFLOAT_MAX) // - 40 For cell padding lineBreakMode:NSLineBreakByWordWrapping];

an example on a label would be

[label setLineBreakMode:NSLineBreakByWordWrapping];

Instead of

label.lineBreakMode = UILineBreakModeWordWrap;

typedef enum {
   UILineBreakModeWordWrap = 0,
   UILineBreakModeCharacterWrap,
   UILineBreakModeClip,
   UILineBreakModeHeadTruncation,
   UILineBreakModeTailTruncation,
   UILineBreakModeMiddleTruncation,
} UILineBreakMode;


   UILineBreakModeWordWrap = 0,
   以单词为单位换行,以单位为单位截断。
   UILineBreakModeCharacterWrap,
   以字符为单位换行,以字符为单位截断。
   UILineBreakModeClip,
   以单词为单位换行。以字符为单位截断。
   UILineBreakModeHeadTruncation,
   以单词为单位换行。如果是单行,则开始部分有省略号。如果是多行,则中间有省略号,省略号后面有4个字符。
   UILineBreakModeTailTruncation,
   以单词为单位换行。无论是单行还是多行,都是末尾有省略号。
   UILineBreakModeMiddleTruncation,
   以单词为单位换行。无论是单行还是多行,都是中间有省略号,省略号后面只有2个字符。
0 0
原创粉丝点击