Last active
April 1, 2016 16:59
-
-
Save cbess/6303604 to your computer and use it in GitHub Desktop.
Fix iOS [sizeWithFont:constrainedToSize:lineBreakMode:] deprecation warning. Adjusts the label height (top align text).
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
// adjust the label height (top align text) | |
// old | |
CGSize labelSize = [model.name sizeWithFont:self.nameLabel.font | |
constrainedToSize:_maxNameLabelSize | |
lineBreakMode:self.nameLabel.lineBreakMode]; | |
// new | |
CGSize labelSize = [model.name boundingRectWithSize:_maxNameLabelSize | |
options:NSStringDrawingUsesLineFragmentOrigin | |
attributes:@{NSFontAttributeName: self.nameLabel.font} | |
context:nil].size; | |
// update label (won't compile, but you get it) | |
// self.nameLabel.frame.size.height = labelSize.height; |
furueili
commented
Aug 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment