TableView知识点梳理__一


设置cell的数据
    cell.textLabel.text = hero.name;
    cell.detailTextLabel.text = hero.intro;
    cell.imageView.image = [UIImage imageNamed:hero.icon];

设置cell右边指示器的类型

   if (indexPath.row % 2 == 0) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
   cell.accessoryView = [[UISwitch alloc] init];
 // 设置背景(背景view不用设置尺寸, backgroundView的优先级 > backgroundColor)
    UIImageView *bgView = [[UIImageView alloc] init];
    bgView.image = [UIImage imageNamed:@"buttondelete"];
//    bgView.backgroundColor = [UIColor redColor];
    cell.backgroundView = bgView;

设置选中时候的背景
    UIView *selectedbgView = [[UIView alloc] init];
    selectedbgView.backgroundColor = [UIColor greenColor];
    cell.selectedBackgroundView = selectedbgView;


你可能感兴趣的:(tableview)