Last active
March 14, 2021 18:04
-
-
Save shawn-frank/52e8c00449061e41b9ba8fa063f4ee64 to your computer and use it in GitHub Desktop.
Some lines of code for common customizations required for UITableView and UITableViewCell yet easy to forget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Remove seperator lines between UITableViewCells in UITableView | |
| // Reference: https://stackoverflow.com/questions/26653883/delete-lines-between-uitableviewcells-in-uitableview | |
| var tableView = UITableView() | |
| tableView.separatorStyle = .none | |
| // Add spacing between UITableViewCell | |
| // Reference: https://stackoverflow.com/questions/1369831/eliminate-extra-separators-below-uitableview | |
| // Inside UITableViewCell subclass | |
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| contentView.frame = contentView.frame.inset(by: UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)) | |
| } | |
| // Eliminate extra separators in UITableView | |
| // Reference: https://stackoverflow.com/questions/1369831/eliminate-extra-separators-below-uitableview | |
| var tableView = UITableView() | |
| tableView.tableFooterView = UIView() | |
| // Remove the cell highlight color of UITableView | |
| // Reference: https://stackoverflow.com/a/2787101/1619193 | |
| // Inside UITableViewCell subclass | |
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| selectionStyle = .none | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment