Last active
May 22, 2016 06:34
-
-
Save arlm/5457aa068e0a7a89f88a07f3477a0f80 to your computer and use it in GitHub Desktop.
Get StringSize since iOS7
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
var dictionary = new NSDictionary(UIStringAttributeKey.Font, Font.Name); | |
var attributes = new UIStringAttributes(dictionary); | |
var size = text.GetSizeUsingAttributes(attributes); |
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
var bounds = new SizeF(width, height); | |
var text = new NSString(text ?? string.Empty); | |
var dictionary = new NSDictionary(UIStringAttributeKey.Font, font.Name); | |
var attributes = new UIStringAttributes(dictionary); | |
var options = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin; | |
var size = text.GetBoundingRect(bounds, options, attributes, null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment