UIImage 镜像表现得很奇怪
我有一个按钮可以在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
方向是 UIImage 的属性,而不是如何修改 CGImage 的指令。您必须在
UIImageOrientationUpMirrored
和UIImageOrientationUp
之间交替。The orientation is a property of the
UIImage
, not an instruction how to modify theCGImage
. You'll have to alternate betweenUIImageOrientationUpMirrored
andUIImageOrientationUp
.