La première capture d'écran est iOS7 ce n'est pas ce que je veux.
Première capture d'écran est iOS6 que ce que je veux.
Le style de Tableview est simple.
Le séparateur de Tableview est aucun.
Et il y a un backgroudView de cette couleur darkgray.
J'ai le code comme ci-dessous
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) { [tableView setSeparatorInset:UIEdgeInsetsZero]; } cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"icon_bg_box.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
Vous devez append une vue séparée en tant que séparateur.
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]; [cell addSubview:[self drawSeparationView:(indexPath.row)]]; return cell; }
Puis dessinez votre séparateur
- (UIView*)drawSeparationView:(NSInteger)itemNo { UIView *view = [[UIView alloc] init]; view.frame = CGRectMake(0, 0, self.tableView.frame.size.width, cellHeight); UIView *upperSsortingp = [[UIView alloc]init]; upperSsortingp.backgroundColor = [UIColor colorWithWhite:0.138 alpha:1.000]; upperSsortingp.frame = CGRectMake(0, 0, view.frame.size.width, 2); [view addSubview:upperSsortingp]; UIView *lowerSsortingp = [[UIView alloc]init]; lowerSsortingp.backgroundColor = [UIColor colorWithWhite:0.063 alpha:1.000]; lowerSsortingp.frame = CGRectMake(0, cellHeight-2, view.frame.size.width, 2); [view addSubview:lowerSsortingp]; return view; }
La sortie sera quelque chose comme ça
Cela masquera le séparateur
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Ensuite, ajoutez votre séparateur imageViewView dans chaque cellule en bas.
Essaye ça
self.tableview.separatorColor = [UIColor clearColor];
Si vous voulez supprimer la ligne de séparation de tableviewcell
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Ensuite, ajoutez une ligne de séparation pour la cellule personnalisée
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];/// change size as you need. separatorLineView.backgroundColor = [UIColor grayColor];// you can also put image here [cell.contentView addSubview:separatorLineView];
Les crédits vont à iPatel Answer