Last active
June 8, 2016 21:48
-
-
Save soffes/60de494e9bd53d5ae7b45828ad39140c to your computer and use it in GitHub Desktop.
Thin lines
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
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