【发布时间】:2017-04-21 09:37:58
【问题描述】:
我已经在 viewdidload() 中应用了下面的代码,但是使用这个代码边框已经到达,但是它随着表格内容滚动。我想在顶部和底部修复边框。
这里是我的代码 ->
let topBorder = CAShapeLayer()
let topPath = UIBezierPath()
topPath.move(to: CGPoint(x: 0, y: 0))
topPath.addLine(to: CGPoint(x: tblFilter.frame.width, y: 0))
topBorder.path = topPath.cgPath
topBorder.strokeColor = UIColor.red.cgColor
topBorder.lineWidth = 1.0
topBorder.fillColor = UIColor.red.cgColor
tblFilter.layer.addSublayer(topBorder)
let bottomBorder = CAShapeLayer()
let bottomPath = UIBezierPath()
bottomPath.move(to: CGPoint(x: 0, y: tblFilter.frame.height))
bottomPath.addLine(to: CGPoint(x: tblFilter.frame.width, y: tblFilter.frame.height))
bottomBorder.path = bottomPath.cgPath
bottomBorder.strokeColor = UIColor.red.cgColor
bottomBorder.lineWidth = 1.0
bottomBorder.fillColor = UIColor.red.cgColor
tblFilter.layer.addSublayer(bottomBorder)
给我建议,谢谢
【问题讨论】:
-
从您的代码中不清楚添加图层的位置。
CGPoints的数学运算也不正确,因为图层将被添加到边界之外。
标签: ios swift uitableview layer