5

I've been banging my head against the wall with this one, so maybe someone here has done this before.

Anyway, I'm trying to change how the delete button looks in my UITableView, and I've got it mostly figured out. I'm changing it by setting the background Color to a UIImage of what I actually want it to look like.

Apparently, though, a UITableViewRowAction has a faint grey line under it, and I can't figure out how to make this disappear. Any pointers would be greatly appreciated. There's a link to what I'm talking about here:

enter image description here

Thank you very much!

Kampai
  • 22,848
  • 21
  • 95
  • 95
Kyle Bashour
  • 1,327
  • 2
  • 13
  • 20

2 Answers2

3

This is a separator line of UITableView. You can remove it by setting it's style as None.

Objective C:

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Swift:

self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None

Initially separator line is not visible, because I think height of image or view added in cell is more than cell height.

And that's why while you swipe separator line is visible. If you are testing in Simulator than use Debug > Color Blended Layers of Simultor. Which is helpful to track overlapping views.

enter image description here

Edit:

iOS 8.0 introduced layoutMargins for UITableView. So it may be possible reason for that also.

Check out this answer for more information.

It explains to clear layout margins by setting cell layoutMargins as UIEdgeInsetsZero.

Community
  • 1
  • 1
Kampai
  • 22,848
  • 21
  • 95
  • 95
  • That's not it actually, I thought that too at first :/ I've already done that, and trust me, I can see the separators if I don't, they're not covered up. Thanks though! – Kyle Bashour Jan 06 '15 at 07:05
  • 'Delete' button looks like custom here. So check that line is visible due to custom view. – Kampai Jan 06 '15 at 07:10
  • It doesn't look to be a separator line, based on [this](http://imgur.com/2kac5F1). The custom view is actually a UIImage being using as a background image, and it's simply white. The behavior if it doesn't fill the view is to tile, so the line can't come from that. I really think it's a part of UITableViewRowAction, but I can't find where it is. – Kyle Bashour Jan 06 '15 at 07:16
  • From your reference image it is clear now that it's not overlapping view line. Let me check what other cause here can be. – Kampai Jan 06 '15 at 07:21
  • Do you specified any footer view or table footer view. Some times footer view lines also appears. In earlier iOS version many had faced bottom line issue any it was due to footer view. – Kampai Jan 06 '15 at 07:39
  • Thanks so much for looking. I added this code and it's still the same. Do I need to set an edge other than zero? func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { tableView.separatorInset = UIEdgeInsetsZero tableView.layoutMargins = UIEdgeInsetsZero cell.layoutMargins = UIEdgeInsetsZero } – Kyle Bashour Jan 06 '15 at 20:53
0

Try this on cellForRowAtIndexPath Method

for iOS lower versions

 if(indexPath.row != self.newCarArray.count-1){
   UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 2)];
   line.backgroundColor = [UIColor redColor];
   [cell addSubview:line];
  }

for iOS 7 upper versions

 if (indexPath.row == self.newCarArray.count-1) {
    cell.separatorInset = UIEdgeInsetsMake(0.f, 0.f, 0.f, cell.bounds.size.width);
 }
Soumya Ranjan
  • 4,817
  • 2
  • 26
  • 51