Created
May 27, 2015 12:07
-
-
Save burhanaksendir/ab01fbe778e519532bff to your computer and use it in GitHub Desktop.
SplashScreen animation in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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