我想画虚线下边框到UITableViewCells
用下面的代码:企图拉拢虚线边框的UITableViewCell
func addDashedBottomBorder(to cell: UITableViewCell) {
let width = CGFloat(2.0)
let dashedBorderLayer: CAShapeLayer = CAShapeLayer()
let frameSize = cell.frame.size
let shapeRect = CGRect(x: 0, y: frameSize.height, width: frameSize.width*2, height: 1)
dashedBorderLayer.bounds = shapeRect
dashedBorderLayer.position = CGPoint(x: 0, y: frameSize.height)
dashedBorderLayer.strokeColor = UIColor.lightGray.cgColor
dashedBorderLayer.lineWidth = width
dashedBorderLayer.lineDashPattern = [9, 6]
dashedBorderLayer.path = UIBezierPath(roundedRect: shapeRect, cornerRadius: 5).cgPath
cell.layer.addSublayer(dashedBorderLayer)
}
但是,我得到我的虚线CAN背后一个奇怪的实线在这里看到:http://imgur.com/6kR9PgZ
我已经在viewDidLoad
任何为什么我收到实线背后的虚线一个想法设置tableView.separatorColor = UIColor.clear
?
你检查了答案 –