title: iOS: Mixing Core Graphics draw path and UIKit draw text functions
body: <p>I am using following context in UIView's extended class's drawrect method to draw Paths and Strings.</p>
  
  <pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
  
  CGContextScaleCTM(context, 1, -1);
  CGContextTranslateCTM(context, 0, -rect.size.height);
  </code></pre>
  
  <p>To Draw Path I use</p>
  
  <pre><code>CGContextSetRGBStrokeColor(context, 0, 0, 0, 1.0f);
  CGContextSetLineWidth(context, 1);
  CGContextBeginPath(context);
  CGContextMoveToPoint(context, origin.x, origin.y);
  CGContextAddLineToPoint(context, currentX, origin.y);
  ......
  CGContextStrokePath(context);
  </code></pre>
  
  <p>To Draw text I use </p>
  
  <pre><code>CGContextSetLineWidth(context, 2.0);    
  [self.title drawInRect:CGRectMake(100, 100, 200, 40) withFont:font];
  </code></pre>
  
  <p>I get paths correctly but Text gets up side down! If I remove CGContextScaleCTM and  CGContextTranslateCTM I get path up side down! Can someone help me to resolve this please.</p>