Remove border in each table cell in swift
16,272
Solution 1
You can remove bottom border by writing this below line in viewdidLoad,
self.tblMyTable.separatorStyle = UITableViewCellSeparatorStyle.None
And Remove left padding by writing this in cellForRow,
cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero
Update for Swift 3.0:
cell?.separatorInset = UIEdgeInsets.zero
cell?.layoutMargins = UIEdgeInsets.zero
Solution 2
select tableview in storyboard and select seperator style to None
Solution 3
Another simple solution that worked for me for removing bottom lines (separators) just for empty rows - tested on Swift 4, Xcode 9 & iOS 11:
class viewController: UIViewController {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView?.tableFooterView = UIView()
}
}
Solution 4
I use the method below
class viewController: UIViewController {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.separatorInset = UIEdgeInsetsMake(0, UIScreen.main.bounds.width, 0, 0)
}
}
Author by
May Phyu
Updated on June 14, 2022Comments
-
May Phyu about 2 years
I would like to remove border bottom line of each Question table rows. Another thing is that I would like to remove the left padding space in each row. How to implement it in swift iOS 9.0 .
-
May Phyu about 8 yearsYour code is remove border totally. I just want to remove the border bottom line of "Question" rows. So, if I remove this "Question" and "Answer" looks like in one row/one group. I want like this.
-
Jigar Tarsariya about 8 yearsIt would be better if you display question and answer both in single cell by using Custom cell. Is it possible for you?
-
May Phyu about 8 yearsIt would be great. How could I make it? I'm new for iOS . I'm just learning by viewing tutorials. Currently, I got the data from Rest. .Please help me.
-
Jigar Tarsariya about 8 yearsYou have to give question and answer both in custom cell (two different label or else). I think it will be easy for you.
-
Adrien G over 6 yearsgod I was looking for an "imaginary" bottom extra space... thanks a lot
-
sɐunıɔןɐqɐp almost 6 yearsWelcome to Stack Overflow! Please don't answer just with source code. Try to provide a nice description about how your solution works. See: How do I write a good answer?. Thanks