List of supported attribute keys for NSString.sizeWithAttributes?

℡╲_俬逩灬. 提交于 2019-12-08 17:37:45

问题


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


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/22599108/list-of-supported-attribute-keys-for-nsstring-sizewithattributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!