NSAttributedString
来源:互联网 发布:制作请帖的软件 编辑:程序博客网 时间:2024/04/30 14:48
NSAttributedString
objects manage character strings and associated sets of attributes (for example, font and kerning) that apply to individual characters or ranges of characters in the string. An association of characters and their attributes is called an attributed string. The cluster’s two public classes, NSAttributedString
and NSMutableAttributedString
, declare the programmatic interface for read-only attributed strings and modifiable attributed strings, respectively. The Foundation framework defines only the basic functionality for attributed strings; in Mac OS X, additional methods supporting RTF, graphics attributes, and drawing attributed strings are described in NSAttributedString Additions, found in the Application Kit. The Application Kit also uses a subclass of NSMutableAttributedString
, called NSTextStorage, to provide the storage for the Application Kit’s extended text-handling system.
In Mac OS X, the Application Kit also uses NSParagraphStyle and its subclass NSMutableParagraphStyle to encapsulate the paragraph or ruler attributes used by the NSAttributedString
classes.
An attributed string identifies attributes by name, storing a value under the name in an NSDictionary
object. In Mac OS X, standard attribute keys are described in the “Constants” section of NSAttributedString Application Kit Additions Reference. You can also assign any attribute name/value pair you wish to a range of characters—it is up to your application to interpret custom attributes (see Attributed String Programming Guide). If you are using attributed strings with the Core Text framework, you can also use the attribute keys defined by that framework.
Note that the default font for NSAttributedString
objects is Helvetica 12-point, which differs from the Mac OS X system font Lucida Grande, so you may wish to create the string with non-default attributes suitable for your application using, for example,initWithString:attributes:
.
Be aware that isEqual:
comparison among NSAttributedString
objects compares for exact equality, including not only literal character-by-character string equality but also equality of all attributes, which is not likely to be achieved in the case of many attributes such as attachments, lists, and tables, for example.
iOS Note: In iOS, this class is used primarily in conjunction with the Core Text framework.
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString
- NSAttributedString 详解
- NSAttributedString 详解
- iOS:NSAttributedString
- OnEraseBkgnd、OnPaint与画面重绘
- Unity3D游戏引擎初探
- SELECT语句的执行顺序
- RESIN下配置EJB有四个步骤
- truncate,delete,drop
- NSAttributedString
- NDK Build 参数
- javascript 遍历一个对象object 有时会用到(转自:http://blog.csdn.net/peng_wu01/article/details/5569247)
- UPDATE、DELETE 语句中的子查询
- C++ Vector 使用心得
- 您绝对想不到的 SQL 子查询错误
- 外连接 ON 条件的三个作用及与 WHERE 的区别
- select into 和 insert into select 两种表复制语句
- 使用VS2005网站管理工具的方法