Skip to content

Instantly share code, notes, and snippets.

@alldne
Created February 22, 2020 20:23
Show Gist options
  • Save alldne/a08181f8300e53df20c17ed5bcc4ebcc to your computer and use it in GitHub Desktop.
Save alldne/a08181f8300e53df20c17ed5bcc4ebcc to your computer and use it in GitHub Desktop.
ContentSizeView.swift
class ContentSizeView: UIView {
override var intrinsicContentSize: CGSize {
return contentSize ?? CGSize(width: UIView.noIntrinsicMetric, height: UIView.noIntrinsicMetric)
}
var contentSize: CGSize? {
didSet {
invalidateIntrinsicContentSize()
}
}
init(frame: CGRect, contentSize: CGSize?) {
super.init(frame: frame)
self.contentSize = contentSize
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment