In the following code below, I’m trying to translate, or more a graphics context for which I’m using CoreText to draw on. The first four lines of code flip the coordinate system as CoreText uses the origin from the lower left hand corner. After the coordinate system is flipped I need to move the graphics context down the y axis by textFrameOriginY amount. However the following code I’m using isn’t working. I’m not that familiar with graphics and was wondering if there is something I’m doing wrong?
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CGContextTranslateCTM(context, 0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextTranslateCTM(context, 0, textFrameOriginY);
After you’ve flipped the coordinate syste, down is negative and up is positive, so your second translate should be -textFrameOriginY?
Assuming that this is in -drawRect: – remember that you can’t draw outside of your bounds, that should help you with debugging the issue…