It\'s really a pain, but always when I draw an UIImage in -drawRect:, it\'s upside-down.
When I flip the coordinates, the image draws correctly, but at the cost of a
The better answer to this problem is to use the UIImage
method drawInRect:
to draw your image. I'm assuming you want the image to span the entire bounds of your view. This is what you'd type in your drawRect:
method.
Instead of:
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIImage *myImage = [UIImage imageNamed:@"theImage.png"];
CGImageRef img = [myImage CGImage];
CGRect bounds = [self bounds];
CGContextDrawImage(ctx, bounds, img);
Write this:
UIImage *myImage = [UIImage imageNamed:@"theImage.png"];
CGRect bounds = [self bounds];
[myImage drawInRect:bounds];