原因:因为label自适应宽度得出来的labelsize.width是小数,才会有黑边
去除方法: 将labelsize.width转换成整数,如下:
CGSize size = CGSizeMake(SCREEN_WIDTH,timeLabelHeight);
CGSize labelsize = [_message[@"time"] sizeWithFont:[UIFont fontWithName:@"STHeitiSC-Light" size:timeLabelFontSize]constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
_timeLabel.frame = CGRectMake((SCREEN_WIDTH-labelsize.width-10)/2, 10, (int)labelsize.width+10, timeLabelHeight);
_timeLabel.text = _message[@"time"];
时间: 2024-09-27 04:14:13