Created
January 12, 2017 09:30
-
-
Save josephchang10/821a246f5afbdee5e4f96732066d385a to your computer and use it in GitHub Desktop.
根据文字计算高度
This file contains 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
let fontSize: CGFloat = 22.0 | |
func sizeHeightWithText(labelText: NSString, | |
fontSize: CGFloat, | |
textAttributes: [String : Any]) -> CGRect { | |
return labelText.boundingRect( | |
with: CGSize(width:fontSize, height:480), | |
options: NSStringDrawingOptions.usesLineFragmentOrigin, | |
attributes: textAttributes, context: nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment