2

I am trying to add a clip mask to my image. And then making painting with finger touches on the screen.

Finger touches and clip mask works but the problem is my UIImage looks invert up and down.

How can I correct that?

This is the line of code for my mask:

CGContextClipToMask(context, rect, myIconImage.CGImage);

Thanks

Val Nolav
  • 908
  • 8
  • 19
  • 44

1 Answers1

8

I found the answer and I wanna share it.

It is quite simply actually. Since the CGImage is inverting a UIImage I added these lines before the ClipToMask line:

CGContextTranslateCTM(context, 0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);

with this code, it works!

Val Nolav
  • 908
  • 8
  • 19
  • 44