How to change separator height in UITableView Swift 3?

前端 未结 4 1408
抹茶落季
抹茶落季 2021-01-07 05:59

Although there a few answers already on this topic. None of them cover Swift 3 and they are from a long time ago. What is currently the best way to change the separator heig

4条回答
  •  滥情空心
    2021-01-07 07:00

    Try this Swift 3:

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: YOUR_CELL_IDENTIFIER, for: indexPath) as! yourTableViewCell
    
        let viewSeparatorLine = UIView(frame:CGRect(x: 0, y: cell.contentView.frame.size.height - 5.0, width: cell.contentView.frame.size.width, height: 5))
        viewSeparatorLine.backgroundColor = .red
        cell.contentView.addSubview(viewSeparatorLine)
        return cell
    }
    

提交回复
热议问题