0

I am trying to add border each UIView. The first and the last selected dates should have rounded corners but the masking applied by the rounded corners extension is cropping it out.

I have tried many other solutions but this one seems to be the closest to be true.

Excuse my bad english.

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)
    }
}
alexander.polomodov
  • 5,396
  • 14
  • 39
  • 46
Omar Sb
  • 1
  • 3

2 Answers2

0

Try to add

v.layer.cornerRadius = v.frame.size.width/2
v.layer.maskToBounds = true
Alen Alexander
  • 725
  • 6
  • 22
-1

I think you can do this:

self.(calendar).clipsToBounds
Patrick
  • 1,717
  • 7
  • 21
  • 28