Open3

UITableViewのInsetとCorner Radius

Shun UematsuShun Uematsu

UIRectCornerを用いれば以下のように、特定のCornerのみRadiusをかけられる。

extension UITableViewCell {
    func roundedCorners(_ corners: UIRectCorner, cornerRadius: CGFloat) {
        let maskLayer = CAShapeLayer()
        maskLayer.path = UIBezierPath(roundedRect: self.bounds,
                                      byRoundingCorners: corners,
                                      cornerRadii: CGSize(width: cornerRadius,height: cornerRadius)).cgPath
        self.layer.mask = maskLayer
    }
}