iOS 7 uses NSString::sizeWithAttributes
to calculate the size of the bounding box of an NSString
given an NSDictionary
of attributes. However, I can't find a resource that lists all the enumerated keys available for use in that NSDictionary
.
The NSString UIKit Additions Reference says that
These are the same attributes that can be applied to an NSAttributedString object
but doesn't list them, and they're not listed in the NSAttributedString
documentation either.
Also: of the available attribute keys, which are the most fundamental to sizing a multiline label? It seems that font size and line break mode are the most important, but without a list of the available options it's hard to say...
I search for 20 minutes and then find the answer immediately after posting on SO. Sigh.
For future reference, the available attributes are listed toward the bottom of the NSAttributedString - Foundation Reference, in the Character Attributes section.
Above link is dead. Here is the new one.
let NSAttachmentAttributeName: String
let NSBackgroundColorAttributeName: String
let NSBaselineOffsetAttributeName: String
let NSCursorAttributeName: String
let NSExpansionAttributeName: String
let NSFontAttributeName: String
let NSForegroundColorAttributeName: String
let NSKernAttributeName: String
let NSLigatureAttributeName: String
let NSLinkAttributeName: String
let NSMarkedClauseSegmentAttributeName: String
let NSObliquenessAttributeName: String
let NSParagraphStyleAttributeName: String
let NSShadowAttributeName: String
let NSSpellingStateAttributeName: String
let NSStrikethroughColorAttributeName: String
let NSStrikethroughStyleAttributeName: String
let NSStrokeColorAttributeName: String
let NSStrokeWidthAttributeName: String
let NSSuperscriptAttributeName: String
let NSTextAlternativesAttributeName: String
let NSTextEffectAttributeName: String
let NSToolTipAttributeName: String
let NSUnderlineColorAttributeName: String
let NSUnderlineStyleAttributeName: String
let NSVerticalGlyphFormAttributeName: String
let NSWritingDirectionAttributeName: String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With