13

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 .

enter image description here

Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119
May Phyu
  • 895
  • 3
  • 23
  • 47

4 Answers4

24

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
Adam
  • 3,815
  • 29
  • 24
Jigar Tarsariya
  • 3,189
  • 3
  • 14
  • 38
  • Your 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. – May Phyu May 09 '16 at 06:51
  • 1
    It would be better if you display question and answer both in single cell by using Custom cell. Is it possible for you? – Jigar Tarsariya May 09 '16 at 06:59
  • It 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. – May Phyu May 09 '16 at 07:11
  • You have to give question and answer both in custom cell (two different label or else). I think it will be easy for you. – Jigar Tarsariya May 09 '16 at 07:17
12

select tableview in storyboard and select seperator style to Noneenter image description here

Jack.Right
  • 974
  • 3
  • 14
  • 30
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()

    }
}
deevee
  • 1,550
  • 15
  • 21
1

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)

        }
}
Jeri P.M
  • 399
  • 5
  • 15
  • 2
    Welcome 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?](https://stackoverflow.com/help/how-to-answer). Thanks – sɐunıɔןɐqɐp Jul 06 '18 at 06:45