DipakSonara
DipakSonara

Reputation: 2596

How to remove separator line in iOS 7?

First screenshot is iOS7 that not what I want.
First screenshot is iOS6 that what I want.

Tableview's style is plain.
Tableview's separator is none.

And there is a backgroudView of that darkgray color.

I have code like below

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] ];

enter image description here

enter image description here

Upvotes: 2

Views: 3703

Answers (4)

user3182143
user3182143

Reputation: 9609

If you want to remove the separator line of tableviewcell

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Then add separator line for custom cell

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];

Credits go to iPatel Answer

Upvotes: 0

arturdev
arturdev

Reputation: 11039

This will hide the separator

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Then add your custom separator imageView in every cell at bottom.

Upvotes: 4

Bishal Ghimire
Bishal Ghimire

Reputation: 2610

You need to add separate view as a seperator First make tableViews seperator to none

[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;
    }

Then draw your seperator

- (UIView*)drawSeparationView:(NSInteger)itemNo {
    UIView *view = [[UIView alloc] init];
    view.frame = CGRectMake(0, 0, self.tableView.frame.size.width, cellHeight);

    UIView *upperStrip = [[UIView alloc]init];
    upperStrip.backgroundColor = [UIColor colorWithWhite:0.138 alpha:1.000];
    upperStrip.frame = CGRectMake(0, 0, view.frame.size.width, 2);
    [view addSubview:upperStrip];

    UIView *lowerStrip = [[UIView alloc]init];
    lowerStrip.backgroundColor = [UIColor colorWithWhite:0.063 alpha:1.000];
    lowerStrip.frame = CGRectMake(0, cellHeight-2, view.frame.size.width, 2);

    [view addSubview:lowerStrip];
    return view;
}

The output will be something like this

enter image description here

Upvotes: 9

Gyanendra Singh
Gyanendra Singh

Reputation: 1483

Try this

self.tableview.separatorColor = [UIColor clearColor];

Upvotes: 1

Related Questions