日历中的单元格的边框边框FSCalendar
问题描述:
我正在尝试为每个UIView添加边框。第一个和最后一个选定的日期应该有圆角,但是由圆角扩展应用的遮罩会将其裁剪掉。日历中的单元格的边框边框FSCalendar
我已经尝试了许多其他的解决方案,但这一个似乎是最接近真实的。
对不起,我英语不好。
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)
}
}
答
尝试添加
v.layer.cornerRadius = v.frame.size.width/2
v.layer.maskToBounds = true
请附上屏幕截图 –
重复的https://*.com/questions/3330378/cocoa-touch-how-to-change-uiviews-border-color厚度 –
[可可触摸:如何更改UIView的边框颜色和厚度的可能的重复?](https://*.com/questions/3330378/cocoa-touch-how-to-change-uiviews-border-color厚度) –