开发者

Getting the number of lines of UIButton

I have a UIButton, and 开发者_StackOverflowI am setting the text of the titleLabel with a string containing several "\r\n" for new lines.

//From previous logic, you have numLines = 3

NSString *string = [NSString stringWithString:@"this \r\n is a multi-line \r\n button"];

[button setNumberOfLines:numLines]
[button.titleLabel setLineBreakMode:UILineBreakModeWordWrap];

NSLog(@"number of lines = %d", [button.titleLabel numberOfLines]);

but number of lines = 0 is the output - I guess due to the dynamic number of lines with the word wrap.

How can I get the actual number of lines that the title label takes up, after word wrap?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜