获取UILabel的numberOfLine

    CGFloat textH = [self.label.text boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size.height;
CGFloat lineHeight = self.label.font.lineHeight;
NSInteger lineCount = textH / lineHeight;
NSLog(@"-----:%ld %.f",lineCount,lineHeight);

如果希望UILabel的右面添加更多,比方说显示3行,可以给UILabel设置

self.label.numberOfLines = 3;

在获取UILabel实际的numberOfLine,如果大于,则显示更多按钮

05-08 15:44