swift - 使用 CGAffineTransformMakeRotation 时 UIImageview 旋转不起作用

标签 swift uiview uiimageview cgaffinetransform

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

编码1:

@IBAction func rotateAcn(sender: UIButton) {

rotatingImageVw.transform = CGAffineTransformMakeRotation(0.22)

}

输出1

enter image description here

编码2:

@IBAction func getRotatedImage(sender: UIButton) {

newImageView.image = rotatingImageVw.image

}

输出2

enter image description here

不知道为什么会出现这种情况?我需要 输出 2输出 1 中所示。请指导我如何解决这个问题?

最佳答案

Swift 5 的解决方案:

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

关于swift - 使用 CGAffineTransformMakeRotation 时 UIImageview 旋转不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40194355/

相关文章:

ios - 为什么 UINavigationController 在容器 View 中有意外的大小?

ios - 为什么我的 Swift 程序停滞不前?

iOS:向下移动 UITextField 的底部边框

ios - 在 IOS 中从 UIImage 获取坐标和框架

ios - UNCalendarNotificationTrigger 每小时触发器返回错误的触发日期

ios - fatal error : Dictionary<String, Any> 不符合 Decodable 因为 Any 不符合 Decodable

ios - ReactiveX RxSwift 从可观察对象的连接中获得第一个非错误

ios - 无法触摸自定义编程 UIView 中的 UIButton

ios - 将 UITextView 转换为图像

iOS Swift 检测图像旋转