在项目中使用UIBezierPath给tableView 中cell添加圆角,出现了一条白线。
let bezierPath = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: cell.contentView.frame.size.height), byRoundingCorners: .topRight, cornerRadii: CGSize(width: 10, height: 10))
let shapeLayer = CAShapeLayer()
shapeLayer.frame = cell.contentView.bounds
shapeLayer.path = bezierPath.cgPath
cell.contentView.layer.mask = shapeLayer
效果:
解决方案:
cell.contentView.layer.rasterizationScale = UIScreen.main.scale
cell.contentView.layer.shouldRasterize = true
cell.contentView.layer.maskedCorners = [.layerMaxXMinYCorner]
cell.contentView.layer.cornerRadius = 10
修改后效果:
网友评论