For the More Curious: Flipped Views

Both PDF and PostScript use the standard Cartesian coordinate system, in which y increases as you move up the page. AppKit views follow this model by default. Thus, the origin is usually at the lower-left corner of the view.

For some types of drawing, the math is easier if the upper-left corner is the origin and y increases as you move down the page. Such a view is said to be flipped.

To flip a view, you override the flipped property to return true:

 ​ ​o​v​e​r​r​i​d​e​ ​v​a​r​ ​f​l​i​p​p​e​d​:​ ​B​o​o​l​ ​{​
 ​ ​ ​ ​ ​ ​r​e​t​u​r​n​ ​t​r​u​e​
 ​ ​}​

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.