美文网首页
自适应宽高

自适应宽高

作者: 行走在北方 | 来源:发表于2019-04-29 13:31 被阅读0次

_contentLabel = [[YYLabel alloc] init];
_contentLabel.textAlignment = NSTextAlignmentLeft;
_contentLabel.font = App_font(14);
_contentLabel.text = @"这是默认评论数据";
_contentLabel.textColor = UIColorFromRGB(0x333333);
_contentLabel.numberOfLines = 0;
_contentLabel.preferredMaxLayoutWidth = kDeviceWidth - 30kDeviceRate -10kDeviceRate -100*kDeviceRate;
[self.contentView addSubview:_contentLabel];

[_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(wself.avatarIV.mas_right).offset(5*kDeviceRate);
    make.top.mas_equalTo(wself.avatarLabel.mas_bottom).offset(15*kDeviceRate);
    make.right.mas_equalTo(wself.contentView.mas_right);
    
}];

_timeLabel = [[UILabel alloc] init];
_timeLabel.textAlignment = NSTextAlignmentLeft;
_timeLabel.font = App_font(11);
_timeLabel.textColor = UIColorFromRGB(0x666666);
[self.contentView addSubview:_timeLabel];
CGSize userTimeSize = [[_timeLabel.attributedText string] sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:App_font(11),NSFontAttributeName, nil]];
_timeLabel.preferredMaxLayoutWidth = userTimeSize.width;
[_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(wself.contentLabel.mas_left);
    make.top.mas_equalTo(wself.contentLabel.mas_bottom).offset(11*kDeviceRate);
    make.height.mas_equalTo(11*kDeviceRate);
}];

相关文章

网友评论

      本文标题:自适应宽高

      本文链接:https://www.haomeiwen.com/subject/airynqtx.html