式守同学不只可爱而已

2023-09-11更新 / 6.9分 / 爱情,动画 / 日本 / 2022

式守同学不只可爱而已剧情简介

" ]; UIColor *color = [UIColor colorWithRed:0.902f green:0.886f blue:0.863f alpha:1.0f]; self.tableView.backgroundColor = color; self.tableView.separatorColor = [UIColor clearColor]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;}- (void)viewDidLoad { [super viewDidLoad]; [self.tableView registerClass:[NewsTitleCell class] forCellReuseIdentifier:@"cell"]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellOther"];}#pragma mark - Table view data source- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _titleArr.count * 2;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row % 2 == 0) { NewsTitleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.titleLabel.text = _titleArr[indexPath.row/2]; cell.summaryLabel.text = _summaryArr[indexPath.row/2]; return cell; } else { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellOther" forIndexPath:indexPath]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.numberOfLines = 0; cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; cell.textLabel.text = _summaryArr[indexPath.row/2]; return cell; }}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row % 2 != 0) { return 40 [self calculateSizeWithString:_summaryArr[indexPath.row/2] font:[UIFont systemFontOfSize:14] maxW:kWindowW - 30].height; } else { return 80.0f; }}- (CGSize)calculateSizeWithString:(NSString *)string font:(UIFont *)font maxW:(CGFloat)maxW{ CGSize maxSize = CGSizeMake(maxW, MAXFLOAT); // 计算文字 CGRect rect = [string boundingRectWithSize:maxSize options:nil attributes:nil context:nil]; NSDictionary *dict = @{NSFontAttributeName : font}; CGRect rect = [string boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil]; CGSize size = rect.size; return size; }@end

猜你喜欢

露珠日记第一季

2023/美国/剧情,动画,冒险

开心超人联盟之英雄归来

9.1 2016/大陆/喜剧,科幻,动画,儿童,冒险

美食大冒险第二季

7.8 2015/大陆/喜剧,动作,动画,儿童,奇幻,冒险