How to flip the origin.y of an CGRect?
Posted
by mystify
on Stack Overflow
See other posts from Stack Overflow
or by mystify
Published on 2010-04-23T09:11:17Z
Indexed on
2010/04/23
9:13 UTC
Read the original article
Hit count: 488
iphone
I'm trying to draw an UIImageView, but the frame's origin is wrong when I flip the coordinate system for drawing not upside-down.
CGRect imgRect = imgView.frame;
imgRect.origin.y += 10.0f;
CGContextTranslateCTM(context, 0.0f, imgRect.size.height);
CGContextScaleCTM(context, 1.0f, -1.0f);
CGContextDrawImage(context, imgRect, imgView.image.CGImage);
like you can see I move the image down by 10, but instead of going down by 10, it goes UP by 10. That's completely unlogical since I had actually inverted the wrong coordinate system to look exactly like the one in UIView, right? What to do about it?
© Stack Overflow or respective owner