Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your confusion is quite understandable.</p> <p>In truth, a positive angle represents a rotation from the positive X axis toward the positive Y axis. A negative angle represents a rotation from the positive X axis toward the negative Y axis.</p> <p>The “native” Core Graphics coordinate system is modeled after the standard <a href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system" rel="noreferrer">Cartesian coordinate system</a>, in which the Y axis increases <strong>upward</strong> on the page. In this system, a positive angle represents a counter-clockwise rotation:</p> <p><img src="https://i.stack.imgur.com/B2Juq.png" alt="normal coordinate system"></p> <p>So if you create your own <code>CGContext</code> (for example, by using <code>CGBitmapContextCreate</code> or <code>CGPDFContextCreate</code>), rotations will work as you expect.</p> <p>However, computer systems have historically used a coordinate system in which the Y axis increases <strong>downward</strong> on the page. In a flipped coordinate system like this, a positive angle represents a clockwise rotation:</p> <p><img src="https://i.stack.imgur.com/W7mBB.png" alt="flipped coordinate system"></p> <p>Notice that in both coordinate systems, a positive angle rotates from the positive X axis toward the positive Y axis.</p> <p>It turns out that UIKit flips the coordinate system of the graphics contexts that it creates for you. This includes the graphics context it sets up before sending you <code>drawRect:</code> and the graphics context it sets up in <code>UIGraphicsBeginImageContext</code>. (The <a href="http://developer.apple.com/library/ios/DOCUMENTATION/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_overview/dq_overview.html#//apple_ref/doc/uid/TP30001066-CH202-CJBBAEEC" rel="noreferrer"><em>Quartz 2D Programming Guide</em></a> explains this.) You can check this by looking at the current transform matrix (using <code>CGContextGetCTM</code>). You will find that it has a <code>-1</code> in its <code>d</code> element, meaning that the Y axis is flipped.</p> <p>A <code>UIView</code> also uses a flipped coordinate system for laying out its subviews, which affects the meaning of the <code>UIView</code> <code>transform</code> property.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload