首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JTAppleCalendar -如何停止随机重复的单元格?

JTAppleCalendar -如何停止随机重复的单元格?
EN

Stack Overflow用户
提问于 2017-11-28 03:31:00
回答 0查看 162关注 0票数 0

我在cellForItemAt方法中画了一个圆,对于特定的条件,如下所示:

代码语言:javascript
复制
    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中使用下面的代码,但是它会删除单元格中的所有内容。

代码语言:javascript
复制
func calendar(_ calendar: JTAppleCalendarView, willDisplay cell: JTAppleCell, forItemAt date: Date, cellState: CellState, indexPath: IndexPath) {
    // comment
    cell.layer.sublayers?.forEach { $0.removeFromSuperlayer() }
}

如何具体删除cellForItemAt中添加的shapeLayer?任何帮助都将不胜感激。谢谢。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47518452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档