728x90
출처 : ios - Swift - How to animate Images? - Stack Overflow
// // ViewController.swift // AniImage // // Created by bluesanta on 2017. 6. 10.. // Copyright © 2017년 bluesanta. All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var indicatorImage: UIImageView! var imageArray = [UIImage]() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. for i in 1...5 { imageArray.append(UIImage(named: String(format : "%02d.png", i))!) } indicatorImage.animationImages = imageArray indicatorImage.animationDuration = 0.7 } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func startClicked(_ sender: UIButton) { indicatorImage.startAnimating() } @IBAction func stopClicked(_ sender: UIButton) { indicatorImage.stopAnimating() } }
728x90