https://github.com/eonist/cellhider
🙈 Hide cells in UITableView
https://github.com/eonist/cellhider
uitableview uitableviewcell uitableviewcontroller
Last synced: 11 months ago
JSON representation
🙈 Hide cells in UITableView
- Host: GitHub
- URL: https://github.com/eonist/cellhider
- Owner: eonist
- License: mit
- Created: 2020-05-02T18:16:05.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-11T14:47:49.000Z (almost 5 years ago)
- Last Synced: 2025-01-16T15:52:46.361Z (about 1 year ago)
- Topics: uitableview, uitableviewcell, uitableviewcontroller
- Language: Swift
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://codebeat.co/projects/github-com-passbook-cellhider-master)
[](https://github.com/sentryco/CellHider/actions/workflows/Tests.yml)
# CellHider 🙈
Hide cells in UITableView
### Installation:
- SPM: `.package(url: "https://github.com/passbook/CellHider.git", .branch("master"))`
### Note:
```swift
extension TableView {
/**
* On cell-tap
*/
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
CellHider.hide(table: self, indexPaths: [indexPath], isHidden: true) // hides cells you click
}
/**
* Returns the height of each cell
* - Note: we have to set height to zero when hiding cells
*/
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let cell = self.subviews.compactMap { $0 as? UITableViewCell }.first { self.indexPath(for: $0) == indexPath } // this is the only way to get access to cell during creation
return cell?.isHidden ?? false ? CGFloat.leastNonzeroMagnitude : 60 // or use UITable.automatic...
}
}
```
### Fun fact:
- An alternative name idea for this repo was: "peek-a-boo"