O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20 Drawing Text with Attributes

In Chapter 17, we covered drawing shapes with NSBezierPath. A natural progression from there would be to draw text. In this chapter you will add support for drawing text on the die face to extend the range to [0, 9]. At the end of this chapter, your application will look like Figure 20.1.

Figure 20.1  Completed application

Completed application

NSFont

Overall, the class NSFont has only two types of methods:

  1. class methods for getting the font you want

  2. methods for getting metrics on the font, such as letter height

The following are commonly used methods in NSFont:

 ​ ​c​l​a​s​s​ ​f​u​n​c​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required