简体   繁体   中英

iOS 8: Remove Underline from UITableViewRowAction

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:

在此输入图像描述

Thank you very much!

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.

在此输入图像描述

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM