实例讲解iOS应用开发中使用UITableView创建自定义表格

2020-01-14 19:52:03王冬梅

             
            replyNo_label.frame = CGRectMake(170, 45, 95, 24);          // 改变跟帖数量Label的坐标
             
            [cell addSubview:replyNo_label];                            // 添加跟帖数量Label
        }
        // 独家新闻,只添加独家标志
        else if(model.reportType == NEWSReportExclusive){
             
            extra_view.backgroundColor = [UIColor redColor];            // 设置背景颜色
             
            [extra_view setTitle:@"专题" forState:UIControlStateNormal]; // 设置标题
             
            [cell addSubview:extra_view];                               // 添加到cell
        }
/********************/
    在if(cell==nil)后
复制代码
/*****自定义cell******/
    [image_view setImage:[UIImage imageNamed:model.news_image]];// 设置图片
    title_label.text    = model.news_title;                     // 设置标题
    summary_label.text  = model.news_summary;                   // 设置小标题
    replyNo_label.text  = [NSString stringWithFormat:@"%d 跟帖",model.news_replyNo];// 设置跟帖数量
/********************/
5.设置行高
复制代码
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 75;
}

注:相关教程知识阅读请移步到IOS开发频道。