So I have a checklist type of thing going. However I decided to have the checkmarks appear on the left side of my cells. To accomplish this I am having each cell show a checkmark png image with cell.imageView?.image = UIImage(named: "check")
. This is working fine, however I am running into the problem where the separator line does not appear below the check mark as shown below. I don't like how this looks since the empty cell separators extend the whole length of the cell. Any suggestions to make the separator visible below the image?
You can also change this in Storyboard:
When selecting the table view cell, change Separator
to Custom Insets
and fill in the desired insets.
Add this method to the data source of your table view:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.separatorInset = .zero
}
or do the same thing in the -tableView:cellForRowAtIndexPath:
method.
For Objective-C:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
[cell setSeparatorInset:UIEdgeInsetsZero];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With