06.|06. Drawing Attributed Strings
The Application Kit’s NSStringDrawing extensions let you draw an attributed string in a focused graphics context (typically an NSView) using a number of methods: drawAtPoint:
, drawInRect:
, and (with OS X v10.4 and later) drawWithRect:options:
. These methods are designed for drawing small amounts of text or text that must be drawn rarely. They create and dispose of various supporting text objects every time you call them. To draw strings repeatedly, it is more efficient to use NSLayoutManager, as described in Drawing Strings.
- Application Kit的NSStringDrawing扩展允许您使用多种方法在聚焦图形上下文(通常是NSView)中绘制属性字符串:drawAtPoint:,drawInRect:和(使用OS X v10.4及更高版本)drawWithRect:options:。 这些方法用于绘制少量必须很少绘制的文本或文本。 每次调用它们时,它们都会创建和处理各种支持文本对象。 要重复绘制字符串,使用NSLayoutManager会更有效,如Drawing Strings中所述。
drawAtPoint:withAttributes:
, drawInRect:withAttributes:
, and (with OS X v10.4 and later) drawWithRect:options:attributes:
, are described in NSString Additions.- 请注意,Application Kit也定义了NSString的绘制方法,允许任何字符串对象绘制自己。 这些方法,drawAtPoint:withAttributes:,drawInRect:withAttributes:和(与OS X v10.4及更高版本)drawWithRect:options:attributes:,在NSString Additions中描述。
boundingRectWithSize:options:
. Again, there is an analogous method to determine the rectangle required to render an NSString object, given a set of attributes—boundingRectWithSize:options:attributes:
.- 使用OS X v10.4及更高版本,您可以使用boundingRectWithSize:options:找出布局属性字符串所需的矩形。 同样,给定一组属性boundingRectWithSize:options:attributes:,有一种类似的方法来确定呈现NSString对象所需的矩形。
推荐阅读
- 206.6.11
- 12306车站代号
- 使用NSAttributedString富文本踩到的坑
- 给你的第四封信
- 006.勇于面对风雨,敢于承担一切后果_20200115
- 丰盛日记2018.06.23天气:晴
- 感恩日志|感恩日志 第【991】天((2018.06.11))
- 亲子日记(173)一六李心宇妈妈
- 纨扇来遮面,美人不相见|纨扇来遮面,美人不相见 06.到底有着怎样的过去()
- 《越学习越不会分析》坚持第2012天原创分享(2020.06.10星期三)