- 코드
class TableViewCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setView()
}
override func layoutSubviews() {
super.layoutSubviews()
// Cell 간격 조정
contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6))
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
func setView() {
// Cell 둥근 모서리 적용(값이 커질수록 완만)
contentView.layer.cornerRadius = 10
}
}
- 결과
Reference
[iOS - swift] tableView cell 간 간격 설정, cell 선택 UI (contentView.frame.inset, setSelected)