Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 20. Drawing Text with Attributes > Drawing Strings and Attributed Strin...

Drawing Strings and Attributed Strings

Both NSString and NSAttributedString have methods that cause them to be drawn onto a view. NSAttributedString has the following methods:

- (void)drawAtPoint:(NSPoint)aPoint

Draws the receiver. aPoint is the lower-left corner of the string.

- (void)drawInRect:(NSRect)rect

Draws the receiver; all drawing occurs inside rect. If rect is too small for the string to fit, the drawing is clipped to fit inside rect.

- (NSSize)size

Returns the size that the receiver would be if drawn.

NSString has analogous methods. With NSString, you need to supply a dictionary of attributes to be applied for the entire string.

- (void)drawAtPoint:(NSPoint)aPoint
     withAttributes:(NSDictionary *)attribs

Draws the receiver with the attributes in attribs.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial