title: Quartz 2D drawing primitives Rotation
body: <p>I'm new to Quartz 2D. I'm trying to draw a triangle then rotate. With my limited background using Quartz 2D I found from Apple/googling that i can use <code>CGContextRotateCTM</code> function . My problem is when i do that the whole text i draw after that is also rotated. I tried using <code>CGContextSaveGstate</code> and restoring it after i do the rotation but didnt work. I'm wondering if my approach is correct? Or there is a better way I can use to achieve that?</p>
  
  <pre><code>  CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    for (key in data) 
    {
      // get point 
      Data *tmpdata =[data objectForKey:key]  ;
      point=[data point ] 
      //setup and draw the 
      CGContextBeginPath(context);
      CGContextSetRGBFillColor(context, [data fillcolor].r, 
          [data fillcolor].g, [tmpACdata fillcolor].b, 1);
      CGContextSetLineWidth(context, 2.0
  
      // Draw Triangle         
      CGContextMoveToPoint(context,point.x,point.y);
      CGContextAddLineToPoint(context, point.x+8, point.y+8);
      CGContextAddLineToPoint(context, point.x-8, point.y+8); 
  
      CGContextClosePath(context);
      CGContextDrawPath(context, kCGPathFill);
  
      CGContextRotateCTM(context, [data heading]* M_PI/180);
  
      CGContextClosePath(context);
      CGContextDrawPath(context, kCGPathFill);
      // Draw Text
      ...............
    }
    CGContextRestoreGState(context);
  </code></pre>