创建纯洁的TableViewCell

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //    声明静态字符串型对象,用来标记重用单元格

    static NSString *str = @"TableSampleIdentifier";

    //    用TableSampleIdentifier表示需要重用的单元

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];

    //    如果如果没有多余单元,则需要创建新的单元

    if (!cell) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];

    }

    //    填充行的详细内容

    cell.detailTextLabel.text = @"详细内容";

    

    //    表视图单元提供的UILabel属性,设置字体大小

    cell.textLabel.font = [UIFont boldSystemFontOfSize:40.0f];

    //    设置单元格UILabel属性背景颜色

    cell.textLabel.backgroundColor=[UIColor clearColor];

    return cell;

}

原文地址:https://www.cnblogs.com/yyj900165/p/4856708.html