self.commentNumber=[[UILabel alloc]init];
self.commentNumber.numberOfLines=0;
self.commentNumber.text=[NSString stringWithFormat:@"%@",self.model.comment_num];
CGRect rectcomment = [self.commentNumber.text boundingRectWithSize:size options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : Font11} context:nil];
[self.commentNumber setFont:[UIFont systemFontOfSize:11]];
[self.commentNumber setTextColor:[UIColor grayColor]];
[self.commentNumber sizeToFit];
self.commentNumber.textAlignment=NSTextAlignmentCenter;
[self.contentView addSubview:self.commentNumber];
self.commentNumber.sd_layout
.rightSpaceToView(self.likeBtn,15)
.topSpaceToView(self.contentLa,11)
.widthIs(rectcomment.size.width)
.heightIs(rectcomment.size.height);
把赋值放在自适应的前面就可以了
网友评论