-
-
Save sekny/784249078fbe4636617fe73858111441 to your computer and use it in GitHub Desktop.
Table View for work with FittedSheets
This file contains 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
import UIKit | |
class TableViewFittedContent: UITableView { | |
override var contentSize: CGSize { | |
didSet { | |
self.invalidateIntrinsicContentSize() | |
} | |
} | |
override var intrinsicContentSize: CGSize { | |
self.layoutSubviews() | |
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height) | |
} | |
func setupTableView<T : UITableViewCell>(cell: T.Type, rowHeight: CGFloat = 30) { | |
self.register( | |
UINib(nibName: cell.className, bundle: nil), | |
forCellReuseIdentifier: cell.className | |
) | |
self.bounces = true | |
self.translatesAutoresizingMaskIntoConstraints = false | |
self.contentInsetAdjustmentBehavior = .never | |
self.showsVerticalScrollIndicator = false | |
self.showsHorizontalScrollIndicator = false | |
// self.isScrollEnabled = true | |
self.rowHeight = CGFloat(rowHeight) | |
self.separatorStyle = .none | |
self.backgroundColor = .clear | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment