1
因此,對於加載動畫,我有一個圖像視圖循環顯示一組圖像。事情是,當它完成循環時,它會返回到數組的第一個圖像,即使我希望它在最後一個圖像上完成。我嘗試將其設置爲完成塊中的最後一個圖像(我當前註釋掉了該行),但它不起作用。有什麼建議麼?謝謝!以第一張圖像結尾的動畫數組
import UIKit
class ViewController: UIViewController {
var logoImageView = UIImageView()
var labelImageView = UIImageView()
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBarHidden = true
self.view.backgroundColor = UIColor(red: (253/255), green: (78/255), blue: (23/255), alpha: 1)
//sets up logo
logoImageView = UIImageView(frame: CGRectMake(self.view.frame.size.width/2 - 65, self.view.frame.size.height/2 - 165, 0, 0))
logoImageView.image = UIImage(named: "00")
logoImageView.backgroundColor = UIColor.clearColor()
self.view.addSubview(logoImageView)
//sets up ilmatic text label
labelImageView = UIImageView(frame: CGRectMake(self.view.frame.size.width/2 - 70, self.view.frame.size.height/2 - 7, 140, 14))
labelImageView.image = UIImage(named: "00_word_mark")
labelImageView.backgroundColor = UIColor.clearColor()
labelImageView.alpha = 0
self.view.addSubview(labelImageView)
//get bigger animation
self.getBigger()
}
func getBigger(){
UIView.animateWithDuration(2, animations: {() -> Void in
self.logoImageView.frame = CGRectMake(self.view.frame.size.width/2 - 65, self.view.frame.size.height/2 - 165, 130, 130)
}) { (completion) -> Void in
self.performSelector("animate", withObject: self, afterDelay: 0.5)
}
}
func animate() {
UIView.animateWithDuration(2, animations: {() -> Void in
let animationImages:[UIImage] = [UIImage(named: "00")!, UIImage(named: "02")!, UIImage(named: "03")!, UIImage(named: "04")!, UIImage(named: "05")!, UIImage(named: "06")!, UIImage(named: "07")!, UIImage(named: "08")!, UIImage(named: "09")!, UIImage(named: "10")!, UIImage(named: "11")!, UIImage(named: "12")!, UIImage(named: "13")!, UIImage(named: "14")!, UIImage(named: "15")!, UIImage(named: "16")!, UIImage(named: "17")!, UIImage(named: "18")!, UIImage(named: "19")!, UIImage(named: "20")!, UIImage(named: "21")!, UIImage(named: "22")!, UIImage(named: "23")!, UIImage(named: "24")!, UIImage(named: "25")!, UIImage(named: "26")!]
self.logoImageView.animationImages = animationImages
self.logoImageView.animationRepeatCount = 1
self.logoImageView.animationDuration = 2
self.logoImageView.startAnimating()
}) { (completion) -> Void in
UIView.animateWithDuration(4, animations: {() -> Void in
// self.logoImageView.image = UIImage(named: "26")
^^^THE ABOVE LINE DOESN T SET THE IMAGE BACK FOR SOME REASON
self.labelImageView.alpha = 0
self.labelImageView.alpha = 1
}, completion: { (completion) -> Void in
self.performSelector("pushToCreateVC", withObject: self, afterDelay: 2)
})
}
}
func pushToCreateVC() {
let createVC = CreateAccountViewController()
self.navigationController?.pushViewController(createVC, animated: true)
}
}