我已将UIImageView
作为子视图添加到UIView类型的containerView
。
UIImageView有一些转换(缩放和旋转)。当我更改设备方向时,图像的变换也会改变。
旋转前
旋转后
该如何解决?
更新:这是转换代码
code
func scale(手势:UIPinchGestureRecognizer){
if gesture.numberOfTouches < 2 {
return
}
if gesture.state == .began {
lastScale = 1.0
lastPoint = gesture.location(in: self)
} else if gesture.state == .ended {
adjustMinimumRect()
return
}
// Scale
let scale = 1.0 - (lastScale - gesture.scale)
layer.setAffineTransform(layer.affineTransform().scaledBy(x: scale, y: scale))
lastScale = gesture.scale
// Translate
let point = gesture.location(in: self)
layer.setAffineTransform(layer.affineTransform().translatedBy(x: point.x - lastPoint.x,
y: point.y - lastPoint.y))
lastPoint = gesture.location(in: self)
}