Created
August 27, 2017 17:54
-
-
Save ftp27/9f1bd079fdf208c7df369057bb404b79 to your computer and use it in GitHub Desktop.
Simple way for creating self sizing UITableViews
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
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