【发布时间】:2016-08-26 13:33:30
【问题描述】:
我的问题很简单,如何在UITableView中实现这样的分隔符。
我曾经尝试通过此代码将包含虚线的 CAShapeLayer 添加到 Cell.layer
let screenWidth = UIScreen.mainScreen().bounds.width
let path = UIBezierPath(); path.lineWidth = 0.2
path.moveToPoint(CGPointMake(10, cell.height))
path.addLineToPoint(CGPointMake(screenWidth - 20, cell.height))
let shapeLayer:CAShapeLayer = CAShapeLayer()
shapeLayer.strokeColor = UIColor.blackColor().colorWithAlphaComponent(0.3).CGColor
shapeLayer.fillColor = nil
shapeLayer.lineDashPattern = [1,3]
shapeLayer.path = path.CGPath
cell.layer.addSublayer(shapeLayer)
但它不适用于自调整大小的表格视图单元格
tableView.rowHeight = UITableViewAutomaticDimension
感谢您的帮助!
【问题讨论】:
标签: swift uitableview