Set the border color of the UITableView section for each section

I use UITableView with grouping. In my first group, I created a custom cell without a background color, and I would also like to remove the border around the cell. How can I do this for only one section?

For my first cell, I would like to set the border / seperator style to [UIColor clearColor].

enter image description here

EDIT: Apple does this in its contact application, and I wanted to create something like that.

+4
source share
3 answers

I believe that Apple uses tableView:viewForHeaderInSection: for section 0 instead of the cell in the first section for its contact header. You can still specify a transparent background, and a strip will be shown behind it. There will be no borders, because there are no borders in the headings of sections with divided tables.

Regardless of whether you built your own cell in Interface Builder or using code, to transfer these views from a UITableViewCell to a UIView for use with tableView:viewForHeaderInSection: should be a pretty trivial task.

I don’t know if you can save the Details heading, for example, section 1 , if you do not make a label containing this word, and add it to section 0 heading manually.

+3
source
 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.section == 0){ cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; } } 
+4
source

If I understand your question, in cellForRawIndexPath you should add -

 if(indexPath.section==0){ //set the style you wish to add only to the first section } 

luck

EDIT

I use this function for this -

 +(void)setTransparentBgToCell:(UITableViewCell*)cell{ UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)]; backgroundView.backgroundColor = [UIColor clearColor]; cell.backgroundView = backgroundView; [backgroundView release]; cell.selectionStyle=UITableViewCellSelectionStyleNone; cell.textLabel.backgroundColor = [UIColor clearColor]; cell.detailTextLabel.backgroundColor = [UIColor clearColor]; } 

Shani

+3
source

Source: https://habr.com/ru/post/1337529/


All Articles