美文网首页codeTools
2037-UITableViewCell 的 四种类型

2037-UITableViewCell 的 四种类型

作者: ArrQing | 来源:发表于2017-03-02 15:09 被阅读13次
  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell;
    switch (indexPath.row) {
    case 0:
    {
    cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELL1];
    cell.backgroundColor = [UIColor yellowColor];
    cell.selectionStyle = UITableViewCellSelectionStyleDefault;
    }
    break;
    case 1:
    {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CELL2];
    cell.backgroundColor = [UIColor redColor];
    break;
    case 2:
    {
    cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CELL2];
    cell.backgroundColor = [UIColor blueColor];
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    }
    break;
    case 3:
    {
    cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CELL4];
    cell.backgroundColor = [UIColor purpleColor];
    cell.selectionStyle = UITableViewCellSelectionStyleDefault;
    }
    break;
    }
    cell.imageView.image = [UIImage imageNamed:@"warning_btn"];
    cell.detailTextLabel.text = @"detailTextLabel";
    cell.textLabel.text = @"textLabel";
    return cell;

}

图片.png

相关文章

网友评论

    本文标题:2037-UITableViewCell 的 四种类型

    本文链接:https://www.haomeiwen.com/subject/httkgttx.html