swift 3.0水平旋转图像

swift 3.0水平旋转图像,swift,image,Swift,Image,我需要的是水平旋转图像,我正在使用UIView.animate,它工作正常,但问题是图像旋转时的位置发生了变化。我试着用锚点,但没用 当图像旋转时,我必须做什么才能不改变位置 这是我的代码: UIView.animate(withDuration: duration, delay: 0.5, options: [.repeat,.curveEaseInOut,.transitionFlipFromLeft], animations: { targetView.t

我需要的是水平旋转图像,我正在使用UIView.animate,它工作正常,但问题是图像旋转时的位置发生了变化。我试着用锚点,但没用

当图像旋转时,我必须做什么才能不改变位置

这是我的代码:

    UIView.animate(withDuration: duration, delay: 0.5, options: 
    [.repeat,.curveEaseInOut,.transitionFlipFromLeft], animations: {
        targetView.transform = CGAffineTransform(scaleX: -1, y: 1);
    }) { finished in

    }

谢谢,

我不确定它是否在旋转。我认为问题在于你的代码只是移动了它

Swift 3、4

func rotateView(view:UIView) {

    UIView.animate(withDuration: 0.25, delay: 0, options: UIViewAnimationOptions.curveEaseIn, animations: { () -> Void in

        view.transform = CGAffineTransform(rotationAngle: CGFloat.pi * .25)
    }, completion: nil)
}
用法:

rotateView(targetView)

如果我完全错了,请告诉我:)

如果您可以在此处共享这段代码,那就太好了。否则,很难帮助您。@bearacuda13它是EditedTanks@bearacuda13,但我的问题是如何使imageview在X轴上水平旋转。就像它进入屏幕一样。我很困惑。。。你的意思是在x轴上翻转它?您好@bearacuda,正如我现在添加的图像中所示,我希望图像像Y轴上的中间图像一样旋转。(对不起,不是x)。