使用 CGAffineTransformMakeRotation 时 UIImageview 旋转不起作用 [英] UIImageview rotation is not working when using CGAffineTransformMakeRotation

查看:46
本文介绍了使用 CGAffineTransformMakeRotation 时 UIImageview 旋转不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CGAffineTransformMakeRotation 旋转 UIImageView.旋转工作正常.当我尝试将该图像获取到另一个 UIImageView 时,旋转不起作用.

I am rotating UIImageView with CGAffineTransformMakeRotation. Rotation is working fine. When I tried to get that image to another UIImageView , rotation is not working.

编码 1:

@IBAction func rotateAcn(sender: UIButton) {

rotatingImageVw.transform = CGAffineTransformMakeRotation(0.22)

}

输出 1

编码 2:

@IBAction func getRotatedImage(sender: UIButton) {

newImageView.image = rotatingImageVw.image

}

输出 2

我不知道为什么会这样?我需要 Output 2Output 1 一样.请指导我如何解决这个问题?

I dont know why this happening? I need Output 2 as in Output 1 . Kindly guide me how to solve this?

推荐答案

Swift 5 的解决方案:

Solution for Swift 5:

rotatingImageVw.transform = rotatingImageVw.transform.rotated(by: CGFloat(Double.pi / 4))

这篇关于使用 CGAffineTransformMakeRotation 时 UIImageview 旋转不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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