Created
June 21, 2016 11:44
-
-
Save pawankmrai/32ef4c5691e22b88792e98ff38e6080f to your computer and use it in GitHub Desktop.
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
| UILabels and Auto Layout have a problem, because there aren't enough conditions to solve the layout uniquely. | |
| The number of lines in a label is affected by its width, which in turn is affected by the number of lines etc... | |
| To get a label to play nicely, you need to ensure it has a defined width, | |
| it has its number of lines set to 0 and you might need to create a subclass that includes the following: | |
| class MultilineLabelThatWorks : UILabel { | |
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| preferredMaxLayoutWidth = bounds.width | |
| super.layoutSubviews() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment