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 .
Remove border in each table cell in swift
Asked Answered
I think You should use Custom Cell Having two labels for Question & Answer..!!! –
Intitule
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
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. –
Unmitigated
It would be better if you display question and answer both in single cell by using Custom cell. Is it possible for you? –
Carafe
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. –
Unmitigated
You have to give question and answer both in custom cell (two different label or else). I think it will be easy for you. –
Carafe
god I was looking for an "imaginary" bottom extra space... thanks a lot –
Textile
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()
}
}
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)
}
}
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?. Thanks –
Merrie
© 2022 - 2024 — McMap. All rights reserved.