CGContextClipToMask UIImage掩码反转向上和向下 [英] CGContextClipToMask UIImage Mask Invert Up and Down

查看:358
本文介绍了CGContextClipToMask UIImage掩码反转向上和向下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的图片添加剪辑蒙版。
然后在屏幕上用手指触摸进行绘画。

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

手指触摸和剪辑蒙版工作但问题是我的UIImage看起来反转上下。

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

如何更正?

这是我面具的代码行:

CGContextClipToMask(context, rect, myIconImage.CGImage);

谢谢

推荐答案

我找到了答案,我想分享它。

I found the answer and I wanna share it.

实际上很简单。由于CGImage正在反转UIImage,我在ClipToMask行之前添加了这些行:

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);

使用此代码,它有效!

这篇关于CGContextClipToMask UIImage掩码反转向上和向下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆