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?
精彩评论