↓は上左右に12pxのRadiusをつけたサンプル

Contents 非表示
実装
HomeTableViewCell.xib (Storyboardでも可)
テキトーにUIViewを一個入れておく

HomeTableViewCell.swift
import UIKit
final class HomeTableViewCell: UITableViewCell {
// MARK: - Properties
@IBOutlet private weak var customRadiusView: UIView! {
didSet {
customRadiusView.layer.cornerRadius = 12
customRadiusView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
}
}
}
maskedCorners
でRadiusをつけたい部分を指定できます。
各コーナーの名前
名前 | 説明 |
---|---|
.layerMinXMinYCorner | 左上の角(Min X: 左端, Min Y: 上端) |
.layerMaxXMinYCorner | 右上の角(Max X: 右端, Min Y: 上端) |
.layerMinXMaxYCorner | 左下の角(Min X: 左端, Max Y: 下端) |
.layerMaxXMaxYCorner | 右下の角(Max X: 右端, Max Y: 下端) |