In this video tutorial I am going to share with you how to change UITableViewCell separator left side spacing or how to hide table cell separator
If you are looking for a way to work with table cell separator programmatically only, below is a quick example. Otherwise, please watch the video.
Remove UITableViewCell Separator left side space programmatically
- Implement cellForRowAtIndexPath function of your UITableViewDataSource
- Just before returning the value of UITableViewCell, add the two lines which are marked in bold below
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let myCell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as! MyCustomTableViewCell ... myCell.layoutMargins = UIEdgeInsetsZero myCell.separatorInset = UIEdgeInsetsZero return myCell }
Hide UITableViewCell Separator
To hide UITableViewCell separator completely, simply set it’s colour to UIColor.clearColor(). This will make the cell separator not visible.
@IBOutlet weak var myTableView: UITableView! ... override func viewDidLoad() { super.viewDidLoad() self.myTableView.separatorColor = UIColor.clearColor() }
Watch this video for a complete example and please do subscribe if you are interested in more weekly video tutorials like this.
Below are my other tutorials that have to do with UITableViewCell or UITableView
UITableViewController rearrange or reorder table cells example in Swift
I hope this very short video tutorial is of some value to you! 🙂
Happy coding!