【发布时间】: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)
}
}
【问题讨论】:
-
请附上屏幕截图