Skip to content

Instantly share code, notes, and snippets.

@Maxatma
Created March 25, 2020 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maxatma/1ad31dabffc3815d2f533ab1b25bf40e to your computer and use it in GitHub Desktop.
Save Maxatma/1ad31dabffc3815d2f533ab1b25bf40e to your computer and use it in GitHub Desktop.
Self-resizing tableview
class IntrinsicTableView: UITableView {
override var contentSize: CGSize {
didSet {
self.invalidateIntrinsicContentSize()
}
}
override var intrinsicContentSize: CGSize {
self.layoutIfNeeded()
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height + 20)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment