Created
May 17, 2017 15:43
-
-
Save grzegorzkrukowski/e1fd29f6bccfd85679b78130ec106a56 to your computer and use it in GitHub Desktop.
Fixing problem of using Label with autosizing cells
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 UILabelPreferedWidth : UILabel { | |
override var bounds: CGRect { | |
didSet { | |
if (bounds.size.width != oldValue.size.width) { | |
self.setNeedsUpdateConstraints() | |
} | |
} | |
} | |
override func updateConstraints() { | |
if(preferredMaxLayoutWidth != bounds.size.width) { | |
preferredMaxLayoutWidth = bounds.size.width | |
} | |
super.updateConstraints() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment