cellForItemAt
对于特定条件, 我正在以下方法中画一个圆圈:
if cellState.date == CalendarModel.DUE_DATE {
let shapeLayer = CAShapeLayer()
let circlePath = UIBezierPath(arcCenter: CGPoint(x: (cell.layer.frame.size.width)/2,y: (cell.layer.frame.size.height)/2), radius: CGFloat(15), startAngle: CGFloat(0), endAngle:CGFloat(Double.pi * 2), clockwise: true)
shapeLayer.path = circlePath.cgPath
//change the fill color
shapeLayer.fillColor = UIColor.clear.cgColor
//you can change the stroke color
shapeLayer.strokeColor = UIColor.FlatColor.Blue.midnightBlue.cgColor
//you can change the line width
shapeLayer.lineWidth = 1.0
cell.layer.addSublayer(shapeLayer)
}
圆圈一直在随机重复。我正在尝试以下代码,willDisplayCell
但是它会从单元格中删除所有内容。
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
// comment
cell.layer.sublayers?.forEach { $0.removeFromSuperlayer() }
}
如何专门删除shapeLayer
添加的内容cellForItemAt
?任何帮助将不胜感激。谢谢你。