" ]; 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
《式守同学不只可爱而已》由大西沙织 梅田修一朗 松冈美里 日高里菜 冈本信彦 福原绫香 筱 等主演,伊藤良太 山中祥平 导演的爱情,动画...
免責聲明:若本站收錄的資源侵犯了您的權益,我們會及時刪除侵權內容,謝謝合作!