0

I have a UIImageView which I load from nib with autolayout constraints.I am trying to rotate it by 180 deg but when it's rotating it is not holding the center position of its own thus making a weird rotation path. I am rotating the image by this code

//let center = self.viewAnimate.center
UIView.animate(withDuration: 1.3, delay: 0.0, options: [.repeat,.curveEaseInOut], animations: {
                    //self.viewAnimate.center = center
                    self.viewAnimate.transform = self.viewAnimate.transform.rotated(by: CGFloat(Double.pi))
}, completion: nil)

the commented part is done when I thought may be I can force it to holder the center position it had before animation started. How can I solve this issue?

Anuran Barman
  • 1,556
  • 2
  • 16
  • 31
  • Transform looks fine, it could be problem with autolayout, check out this [answer](https://stackoverflow.com/a/21374211/82813) – manikal Dec 28 '18 at 14:44
  • improved the animation by using CABasicAnimation and it became smoother but still weird animation path is there.It is looking like it has lost it center and moving around with changing center – Anuran Barman Dec 28 '18 at 17:14
  • Can you provide video/GIF of it? – manikal Dec 28 '18 at 19:42

0 Answers0