I know i have to translate the coordinate system, when drawing. The thing is that when i use:
CGContextTranslateCTM(_context, 0.0, _size.height);
CGContextScaleCTM(_context, 1.0, -1.0);
My rect of the image is flipped, and the image is ‘non-flipped’, if i dont use the above my image is flipped, and the rect is non-flipped.
Here’s my code:
CGRectMake(60, 100, image.size.width, image.size.height);
CGContextSaveGState(_context);
UIGraphicsBeginImageContext(image.size);
CGContextClearRect(_context, placeholderRect);
CGContextDrawImage(_context, placeholderRect, image.CGImage);
UIGraphicsEndImageContext();
CGContextRestoreGState(_context);
How do i maintain my rect (non-flipped), while the image is flipped?
Thanks
The trick may lie in this UIImage method
Where orientation is one of these 🙂
Edit: Update
I just did this simple code sample in a UIView subclass overriding drawrect and it worked perfectly. It doesn’t use the UIImage method but works all the same.