29,027
社区成员
发帖
与我相关
我的任务
分享
- (void)settingShowTextButton:(UIButton *)showTextButton showIconView:(UIImageView *)showIconView hideTextButton:(UIButton *)hideTextButton hideIconView:(UIImageView *)hideIconView
{
hideTextButton.hidden = YES;
hideIconView.hidden = YES;
showTextButton.hidden = NO;
showIconView.hidden = NO;
// 设置按钮的文字
[showTextButton setTitle:self.message.text forState:UIControlStateNormal];
// 强制更新
[showTextButton layoutIfNeeded];
// 设置按钮的高度就是titleLabel的高度
[showTextButton updateConstraints:^(MASConstraintMaker *make) {
CGFloat buttonH = showTextButton.titleLabel.frame.size.height;
make.height.equalTo(buttonH);
}];
// 强制更新
[showTextButton layoutIfNeeded];
// 计算当前cell的高度
CGFloat buttonMaxY = CGRectGetMaxY(showTextButton.frame);
CGFloat iconMaxY = CGRectGetMaxY(showIconView.frame);
self.message.cellHeight = MAX(buttonMaxY, iconMaxY) + 10;
}