How do I add an extra separator to the top of a UITableView?

后端 未结 8 2108
面向向阳花
面向向阳花 2021-02-06 22:20

I have a view for the iPhone that is basically split in two, with an informational display in the top half, and a UITableView for selecting actions in the bottom half. The prob

8条回答
  •  醉梦人生
    2021-02-06 22:44

    Swift 4

    extension UITableView {
        func addTableHeaderViewLine() {
            self.tableHeaderView = {
                let line = UIView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: 1 / UIScreen.main.scale))
                line.backgroundColor = self.separatorColor
                return line
            }()
        }
    }
    

提交回复
热议问题