I'm creating an animation inside of an iOS application where a shape gets bigger and rotates. I've created the images so they have different sizes inside my photo editor, but when I animate them, they stay at whatever size the very first image is. Here is my current test code:
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
var images = [UIImage]()
var images2 = [UIImage]()
images += [#imageLiteral(resourceName: "circle1"), #imageLiteral(resourceName: "circle2"), #imageLiteral(resourceName: "circle3"), #imageLiteral(resourceName: "circle4")]
images2 += [#imageLiteral(resourceName: "circle4"), #imageLiteral(resourceName: "circle3"), #imageLiteral(resourceName: "circle2"), #imageLiteral(resourceName: "circle1")]
override func viewDidLoad() {
super.viewDidLoad()
imageView.animationImages = images
imageView.animationDuration = 4.0
}
@IBAction func startButton(_ sender: UIButton) {
imageView.startAnimating()
self.perform(#selector(ViewController.secondAnimation), with: nil, afterDelay: 0.9)
}
func secondAnimation() {
imageView.stopAnimating()
imageView.animationImages = images2
imageView.animationDuration = 6.0
imageView.animationRepeatCount = 1
imageView.startAnimating()
}
The images that have lower resolution are stretched and are pixelated to match the size of the other photos. They all have the same relative size on the user interface (UIImageView
). If I reverse the order of the animation, the images being animated are being set to the default size of the first photo again that are of the different size, so I'm certain the animation is using the first image size to set default size on the display.
To simplify my problem as much as possible, the animation is showing the changed resolution, but not showing the proper relative size change of each image. Why is this happening?