Skip to content

Instantly share code, notes, and snippets.

@burhanaksendir
Created May 27, 2015 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burhanaksendir/ab01fbe778e519532bff to your computer and use it in GitHub Desktop.
Save burhanaksendir/ab01fbe778e519532bff to your computer and use it in GitHub Desktop.
SplashScreen animation in Swift
//
// SplashViewController.swift
// splashAnimation
//
// Created by Burhan Aksendir on 26.03.2015.
// Copyright (c) 2015 Aksendir. All rights reserved.
//
import UIKit
class SplashViewController: UIViewController {
@IBOutlet weak var splashAnim: UIImageView!
var timer = NSTimer()
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
splashAnim.animationImages = [UIImage]()
for var index = 0; index < 25; index++ {
var frameName = String(format: "animation_%02d", index)
splashAnim.animationImages?.append(UIImage(named: frameName)!)
}
splashAnim.animationDuration = 1
splashAnim.animationRepeatCount = 1
splashAnim.startAnimating()
timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "endAnimation", userInfo: nil, repeats: false)
}
func endAnimation() {
timer.invalidate()
splashAnim.removeFromSuperview()
splashAnim = nil
self.performSegueWithIdentifier("toMainMenu", sender: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment