Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of supported attribute keys for NSString.sizeWithAttributes?

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...

like image 428
ericsoco Avatar asked Mar 24 '14 00:03

ericsoco


2 Answers

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.

like image 111
ericsoco Avatar answered Nov 07 '22 09:11

ericsoco


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
like image 9
Thanh-Nhon Nguyen Avatar answered Nov 07 '22 11:11

Thanh-Nhon Nguyen