Skip to content

Instantly share code, notes, and snippets.

@ftp27
Created August 27, 2017 17:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftp27/9f1bd079fdf208c7df369057bb404b79 to your computer and use it in GitHub Desktop.
Save ftp27/9f1bd079fdf208c7df369057bb404b79 to your computer and use it in GitHub Desktop.
Simple way for creating self sizing UITableViews
class SelfsizingTableView: UITableView {
override var intrinsicContentSize: CGSize {
return CGSize(width: frame.width,
height: contentSize.height + contentInset.top + contentInset.bottom)
}
override var contentSize: CGSize {
didSet {
if oldValue != contentSize {
invalidateIntrinsicContentSize()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment