lable计算行高

 _introduce.text=status.introduce;
    
    //设置行间距
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:_introduce.text];;
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:7];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, _introduce.text.length)];
    
    _introduce.attributedText = attributedString;
    
    
    NSString *introduce=status.introduce;
    
    CGSize titleSize = [introduce boundingRectWithSize:CGSizeMake(KScreenWidth-80, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
    
    CGFloat height=titleSize.height;
    
View Code

 

posted @ 2016-05-26 11:20  红街咖啡  阅读(264)  评论(0编辑  收藏  举报