2037-UITableViewCell 的 四種類型

  • (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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容