Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- swift documentation
- uiscrollview
- RxCocoa
- Xcode
- 애니메이션
- 리팩토링
- combine
- ios
- uitableview
- SWIFT
- MVVM
- tableView
- ribs
- Clean Code
- clean architecture
- Refactoring
- collectionview
- 스위프트
- 클린 코드
- Observable
- UICollectionView
- 리펙토링
- rxswift
- swiftUI
- UITextView
- map
- scrollview
- HIG
- Human interface guide
- Protocol
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] UITableView의 separatorInset 사용 방법 (셀에 left, right inset 주는 방법) 본문
iOS 응용 (swift)
[iOS - swift] UITableView의 separatorInset 사용 방법 (셀에 left, right inset 주는 방법)
jake-kim 2023. 5. 30. 23:04UITableView의 separatorInset
- cell 안의 내용에 left, right inset을 줄 수 있는 property

- separatorInset은 UIEdgeInsets 타입이라서 top, bottom도 값을 입력할 수 있지만, top, bottom은 적용되지 않음

- separatorInset을 설정하면 해당 padding을 탭했을때도 이벤트를 받아 셀이 선택되므로 padding을 탭해도 선택되게끔 할 때 유용하게 사용이 가능
사용방법
- tableView에서 separatorInset 값을 대입
private let tableView: UITableView = {
let view = UITableView()
view.backgroundColor = .clear
view.separatorStyle = .none
view.bounces = true
view.showsVerticalScrollIndicator = true
view.contentInset = .zero
view.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
view.estimatedRowHeight = 34
view.separatorInset = .init(top: 0, left: 5, bottom: 0, right: 5) // <-
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

* 전체 코드: https://github.com/JK0369/ExSeparatorInset
* 참고
https://developer.apple.com/documentation/uikit/uitableviewcell/1623250-separatorinset
'iOS 응용 (swift)' 카테고리의 다른 글
Comments
