- (void)updateData:(NSMutableArray<SearchCategoriesCellModel *> *)listArr isNormal:(BOOL)isNormal isMoreAlert:(BOOL)isMoreAlert{ self.listArr = listArr; self.isNormal = isNormal;///更换cell ///取余结果:3 一行3个 NSUInteger result = listArr.count % 3; NSUInteger row = 0;///多少行 if (result == 0) { row = listArr.count/3;///行数计算 }else{ row = listArr.count/3 + 1; } ///列表高度 CGFloat listHeight = 0; if (isMoreAlert) {//高度高一些 [self.listBgView mas_updateConstraints:^(MASConstraintMaker *make) { if (@available(iOS 11.0, *)) { make.top.equalTo(self.mas_safeAreaLayoutGuideTop).offset(50); } else { make.top.equalTo(self).offset(50); } }]; if (row * 55 + 20 > 420) { self.listView.showsVerticalScrollIndicator = YES; } listHeight = row * 55 + 20 > 420 ? 420 : row * 55 + 20; }else{ listHeight = row * 55 + 20 > 265 ? 265 : row * 55 + 20 ; if (row * 55 + 20 > 265) { self.listView.showsVerticalScrollIndicator = YES; } } [self.listView mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(listHeight); }]; [self.listView reloadData]; }