Last active
February 27, 2018 07:43
-
-
Save lamlv2305/829cc810f8554bc02c4e28fa1109def2 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
func sizeOfString (string: String, constrainedToWidth width: Double) -> CGSize { | |
let attributes = [NSFontAttributeName:self,] | |
let attString = NSAttributedString(string: string,attributes: attributes) | |
let framesetter = CTFramesetterCreateWithAttributedString(attString) | |
return CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRange(location: 0,length: 0), nil, CGSize(width: width, height: DBL_MAX), nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment