在swift中删除每个表格单元格中的边框

时间:2020-12-27 15:00:25

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 .

我想删除每个Question表行的边框底线。另一件事是我想删除每行中的左边填充空间。如何在swift iOS 9.0中实现它。

在swift中删除每个表格单元格中的边框

3 个解决方案

#1


17  

You can remove bottom border by writing this below line in viewdidLoad,

您可以通过在viewdidLoad中写下以下行来删除底部边框,

self.tblMyTable.separatorStyle = UITableViewCellSeparatorStyle.None

And Remove left padding by writing this in cellForRow,

并通过在cellForRow中写入来删除左边的填充,

cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero 

Update for Swift 3.0:

Swift 3.0的更新:

cell?.separatorInset = UIEdgeInsets.zero
cell?.layoutMargins = UIEdgeInsets.zero

#2


7  

select tableview in storyboard and select seperator style to None在swift中删除每个表格单元格中的边框

在故事板中选择tableview并选择Seperator样式为None

#3


0  

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)

        }
}

#1


17  

You can remove bottom border by writing this below line in viewdidLoad,

您可以通过在viewdidLoad中写下以下行来删除底部边框,

self.tblMyTable.separatorStyle = UITableViewCellSeparatorStyle.None

And Remove left padding by writing this in cellForRow,

并通过在cellForRow中写入来删除左边的填充,

cell.separatorInset = UIEdgeInsetsZero
cell.layoutMargins = UIEdgeInsetsZero 

Update for Swift 3.0:

Swift 3.0的更新:

cell?.separatorInset = UIEdgeInsets.zero
cell?.layoutMargins = UIEdgeInsets.zero

#2


7  

select tableview in storyboard and select seperator style to None在swift中删除每个表格单元格中的边框

在故事板中选择tableview并选择Seperator样式为None

#3


0  

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)

        }
}