0

I have a UIImageView in storyboards with an initial image with AspectFit.

I want to know how I can switch between images with animation but also make this new image have the same aspectFit property as the one loaded through storyboards initially.

This is my code which switches the images but it does not have AspectFit to it. The image looks really small.

func switchImages(){
    let toImage = UIImage(named:"Unlock")

    UIView.transitionWithView(self.myImageView,
        duration:2,
        options: UIViewAnimationOptions.TransitionCrossDissolve,
        animations: {self.myImageView.image = toImage},
        completion: nil)
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
JohnCarp
  • 49
  • 8

1 Answers1

0

Try this!

Also for the aspectFit I believe this can be changed in the UIImageView properties. Just change the Mode to AspectFit!

UIImageView properties. Just change the Mode to AspectFit.

Community
  • 1
  • 1
Kevin Rajan
  • 827
  • 8
  • 28