cell的自适应

+(CGFloat)getCellHeightWithItem:(FXOwnershipStrutureInfo *)item

{

    

    if (item.rowH) {//如有rowH就直接返回,避免重新计算

        return item.rowH;

    }

    //计算cell的行高的关键变高控件的高度

 

    NSMutableParagraphStyle *style =  [[NSParagraphStyle defaultParagraphStyle] mutableCopy];

    style.lineSpacing = 6;

 

    CGRect sizeH = [item.memo boundingRectWithSize:CGSizeMake(ScreenWidth - 105, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSParagraphStyleAttributeName : style} context:nil];

 

 

    //返回高度,并缓存rowH

    return item.rowH = 15 + 20 + 10 + 20 + 10  + sizeH.size.height + 15 + 16 ;

    

}

// 赋值

- (void)addtext

       _showContentLb.frame = CGRectMake(15, _grayLable.bottom+15, ScreenWidth-30, 0);

        _showContentLb.numberOfLines = 0;

        NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:self.item.content];

        NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];

        [paragraphStyle1 setLineSpacing:6];// 行间距

        [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [self.item.content length])];

        [ _showContentLb setAttributedText:attributedString1];//赋值

        [ _showContentLb sizeToFit];

 

 

转载于:https://www.cnblogs.com/weipeng168/p/5259096.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值