Remove separator line for only one cell
On iOS 8 you need to use:
cell.layoutMargins = UIEdgeInsetsZero
If you want to be compatible with iOS 7 as well you should do following:
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
ADD: If previous didn't work - use this. (from answer below)
cell.separatorInset = UIEdgeInsetsMake(0, CGFLOAT_MAX, 0, 0);
If none of above worked, you can do:
self.tableView.separatorColor = [UIColor clearColor];
but this will leave 1 pixel empty space, not really removing a line, more making it transparent.
Hide separator line on one UITableViewCell
in viewDidLoad
, add this line:
self.tableView.separatorColor = [UIColor clearColor];
and in cellForRowAtIndexPath
:
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 (including iOS 8)
if (indexPath.row == self.newCarArray.count-1) {
cell.separatorInset = UIEdgeInsetsMake(0.f, cell.bounds.size.width, 0.f, 0.f);
}
How to remove section header separator in iOS 15
Option 1:
Maybe by using UITableViewCellSeparatorStyleNone
with the table view and replacing the system background view of the cell with a custom view which only features a bottom line?
Option 2: Using hint from https://developer.apple.com/forums/thread/684706
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 // only Xcode 13+ needs and can compile this
if (@available(iOS 15.0, *)) {
[self.tableview setSectionHeaderTopPadding:0.0f];
}
#endif
}
iOS - Removing separator between viewForHeaderInSction and first Cell in UITableView
Separators are set per tableView, so it's not exactly possible to remove them just per cell.
However, if you set the tableview.separatorStyle = .none
, and create a fake separator as a view in your cell at the bottom of the cell, you can achieve the look you're after.
Related Topics
How to Catch Accessibility Focus Changed
Swift: Nil Is Incompatible with Return Type String
Xcode 6 Ignoring Breakpoints - Swift
Custom Mkoverlayrenderer Drawmaprect Function Not Drawing Polygons
Clipping Sound with Opus on Android, Sent from iOS
Live Render Iboutlet Connected Subviews via Ibinspectable Properties
Navigationlink Inside Lazyvgrid Cycles All Entries on Back, Swiftui
Get Light or Dark Variant of a Color Declared in Assets
How to Go Back to Rootviewcontroller from Presentview Controller
iOS Firebase Database Get Key of Value
Wkwebview Is Showing Only Background
Swift: Triggering Tableviewcell to Lead to a Link in a Uiwebview in Another Viewcontroller
Swift3 - How to Protect Secret Key
Changing Constraint When Keyboard Appears - Swift
Please Add the Host Targets for the Embedded Targets to the Podfile