2

I am doing a transition of an UIImageView's image and would also like to move the image view at the same time. The results so far is that the image transitions, but not while moving.

class ViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var imageViewTopConstraint: NSLayoutConstraint!

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        UIView.transition(with: imageView, duration: 2.0, options: .transitionCrossDissolve, animations: {
            self.imageView.image = UIImage(named: "otherImage")
        }, completion: nil)

        imageViewTopConstraint.constant = 200

        UIView.animate(withDuration: 2.0) {
            self.view.layoutIfNeeded()
        }
    }

}

Any ideas on how to solve this?

1
  • Yes, the image does dissolve and move, but I want the dissolve effect to happen while the imageView is moving. It now dissolves in it's initial position and once the transition is done you see the image move. Commented Feb 23, 2017 at 18:16

1 Answer 1

3

You can put your imageView inside a container, then animate the constraints of the container while doing the transition on the imageView.

Sign up to request clarification or add additional context in comments.

2 Comments

Ooooh, that sounds promising. — Yup, tried it. Excellent.
Yeah, this works and I can keep the amount of outlets to 2. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.