UIImage 镜像表现得很奇怪

发布于 2024-12-17 06:24:33 字数 381 浏览 4 评论 0原文

我有一个按钮可以在 imageView 中水平镜像图像。这意味着如果是我举起左手,点击按钮后,它看起来就像是我举起右手的照片。按钮执行的代码如下所示。

有人可以解释为什么第一次单击按钮可以正确镜像图像,但连续单击它不会导致它来回镜像(什么也没有发生)。

-(IBAction)mirrorImage3 {
    UIImage * flippedImage = [UIImage imageWithCGImage:imageView.image.CGImage scale:imageView.image.scale orientation:UIImageOrientationUpMirrored];
    imageView.image = flippedImage;
}

I have a button that mirrors an image horizontally in an imageView. This means if it was an of me holding up my left hand, after clicking the button, it would seem like a picture of me holding up my right hand. The code executed by the button is show below.

Can someone explain why clicking the button the first time, mirrors the image correctly, but clicking it consecutive times does not result in it mirroring itself back and forth (nothing happens).

-(IBAction)mirrorImage3 {
    UIImage * flippedImage = [UIImage imageWithCGImage:imageView.image.CGImage scale:imageView.image.scale orientation:UIImageOrientationUpMirrored];
    imageView.image = flippedImage;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灰色世界里的红玫瑰 2024-12-24 06:24:33

方向是 UIImage 的属性,而不是如何修改 CGImage 的指令。您必须在 UIImageOrientationUpMirroredUIImageOrientationUp 之间交替。

The orientation is a property of the UIImage, not an instruction how to modify the CGImage. You'll have to alternate between UIImageOrientationUpMirrored and UIImageOrientationUp.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文