title: How to animate the view to the center of X and Y?
body: <p>I have an ImageView that have centerX and centerY constraint to the <code>Helper Header View</code> like the image below</p>
  
  <p><a href="https://i.stack.imgur.com/cOTkr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cOTkr.png" alt="enter image description here"></a></p>
  
  <p>I want to animate that logo imageView to be located at the center of the screen like image below:
  <a href="https://i.stack.imgur.com/I8vt2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I8vt2.png" alt="enter image description here"></a></p>
  
  <p>I have tried some code, but it doesn't work, to be honest I am not sure with this code below, here is what I try. maybe you have better approach. here is what I tried</p>
  
  <p>first I try to give identifier to both constraint :
  <a href="https://i.stack.imgur.com/k3Mp0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k3Mp0.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/hfmxE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hfmxE.png" alt="enter image description here"></a></p>
  
  <p>and then I remove the constraint and make a new one like the code below:</p>
  
  <pre><code> UIView.animate(withDuration: 1.1, delay: 0.5, usingSpringWithDamping:  0.4, initialSpringVelocity: 0.0, animations: {
  
              // remove the initial constraint
              self.mainLogoCenterXConstraint.isActive = false
              self.mainLogoCenterYConstraint.isActive = false
  
              // create new constraint
              let newMainLogoCenterXConstraint = NSLayoutConstraint(
                  item: self.mainLogoImageView,
                  attribute: .centerX,
                  relatedBy: .equal,
                  toItem: self.view,
                  attribute: .centerY,
                  multiplier: 1.0,
                  constant: 0)
              newMainLogoCenterXConstraint.identifier = "mainLogoCenterXConstraint"
              newMainLogoCenterXConstraint.isActive = true
  
              let newMainLogoCenterYConstraint = NSLayoutConstraint(
                  item: self.mainLogoImageView,
                  attribute: .centerY,
                  relatedBy: .equal,
                  toItem: self.view,
                  attribute: .centerY,
                  multiplier: 1.0,
                  constant: 0)
              newMainLogoCenterYConstraint.identifier = "mainLogoCenterYConstraint"
              newMainLogoCenterYConstraint.isActive = true
  
  
              self.view.layoutIfNeeded()
  
          }, completion: nil)
  </code></pre>
  
  <p>but it crash and give error:</p>
  
  <blockquote>
    <p>'NSInvalidLayoutConstraintException', reason: 'Constraint improperly
    relates anchors of incompatible types:
    
  </blockquote>
  
  <p>maybe you have better way to achieve this....</p>