13. Drawing Strings

2018-10-29  本文已影响0人  ngugg

You can draw string objects directly in a focused NSView using methods such as drawAtPoint:withAttributes: (to draw a string with multiple attributes, such as multiple text fonts, you must use an NSAttributedString object). These methods are described briefly in Text in Cocoa Drawing Guide.

The simple methods, however, are designed for drawing small amounts of text or text that is only drawn rarely—they create and dispose of various supporting objects every time you call them. To draw strings repeatedly, it is more efficient to use NSLayoutManager, as described in Drawing Stringsin Text Layout Programming Guide. For an overview of the Cocoa text system, of which NSLayoutManager is a part, see Cocoa Text Architecture Guide.

上一篇 下一篇

猜你喜欢

热点阅读