【问题标题】:Rounder border for cells in calendar FSCalendar日历 FSCalendar 中单元格的圆角边框
【发布时间】:2018-03-24 09:29:51
【问题描述】:

我正在尝试为每个 UIView 添加边框。第一个和最后一个选定的日期应该有圆角,但圆角扩展应用的遮罩会将其裁剪掉。

我尝试了许多其他解决方案,但这个似乎是最接近真实的。

请原谅我的英语不好。

extension FSCalendarCell {

    func changeCellStyle(isSelected:Bool, firstIndex:Bool, lastIndex:Bool, color:UIColor){

        let v = UIView(frame: CGRect(x: 0,y: 0,width: self.bounds.width,height: self.bounds.height))

        v.center = self.contentView.center
        v.backgroundColor = UIColor.red
        if firstIndex {
            v.addBorder(edges: [.top,.bottom,.left], color: UIColor.blue, thickness: 2)
            v.roundCorners([.topLeft, .bottomLeft], radius: 10)
        }else if lastIndex {
            v.addBorder(edges: [.top,.bottom,.right], color: UIColor.blue, thickness: 2)
            v.roundCorners([.topRight, .bottomRight], radius: 10)
        }else{
            v.addBorder(edges: [.top,.bottom], color: UIColor.blue, thickness: 2)
        }

        self.contentView.insertSubview(v, at: 0)
    }
}

【问题讨论】:

标签: ios swift calendar


【解决方案1】:

尝试添加

v.layer.cornerRadius = v.frame.size.width/2
v.layer.maskToBounds = true

【讨论】:

    【解决方案2】:

    我认为你可以这样做:

    self.(calendar).clipsToBounds
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-27
      • 2011-08-12
      • 2012-02-18
      • 1970-01-01
      • 1970-01-01
      • 2018-10-25
      • 2020-12-02
      • 2014-09-28
      相关资源
      最近更新 更多