Skip to content

Instantly share code, notes, and snippets.

@soffes
Last active June 8, 2016 21:48
Show Gist options
  • Save soffes/60de494e9bd53d5ae7b45828ad39140c to your computer and use it in GitHub Desktop.
Save soffes/60de494e9bd53d5ae7b45828ad39140c to your computer and use it in GitHub Desktop.
Thin lines
import UIKit
class LineView: UIView {
override func sizeThatFits(size: CGSize) -> CGSize {
return CGSize(width: size.width, height: intrinsicContentSize().height)
}
override func intrinsicContentSize() -> CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 1 / max(1, traitCollection.displayScale))
}
override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
invalidateIntrinsicContentSize()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment