我必须制作一个集合视图,哪些单元格是从左到右舍入的,下面的代码没问题
let maskPath = UIBezierPath(roundedRect: self.bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(width: 10.0, height: 10.0))
let maskLayer = CAShapeLayer()
maskLayer.frame = self.bounds
maskLayer.path = maskPath.CGPath
self.layer.mask = maskLayer
self.layer.masksToBounds = true
但还有一件事,我想给每个单元格的顶部添加边框颜色,
有什么想法吗?
感谢。
答案 0 :(得分:0)
有些差异,所以:
let view = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
let shapeOfView = CAShapeLayer()
shapeOfView.position = view.center
shapeOfView.bounds = view.frame
shapeOfView.path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 10.0, height: 10)).cgPath
view.layer.backgroundColor = UIColor.red.cgColor
view.layer.mask = shapeOfView
答案 1 :(得分:0)
你可以,
var border = CALayer()
border.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 1) //set width and heigt (thickness of your border)
border.backgroundColor = color.CGColor; //desired color
yourCell.layer.addSublayer(border)
答案 2 :(得分:-1)
将CAlayer添加为单元格
的子图层 CALayer *borderLayer = [CALayer layer];
borderLayer.borderColor = [UIColor greenColor].CGColor;
borderLayer.borderWidth = 3.0f;
borderLayer.frame = CGRectMake(0, 0, cell.frame.size.width, 1);
[cell.layer addSublayer:borderLayer];