how to add animation to launch screen in iOS 9.3 using Objective c

how to make a animated splash screen like below image in iOS 9.3.

enter image description here


Basically, you can't make an animated splash screen. However, you can duplicate the launch screen in your storyboard and make it the entrance-view controller (VC) of your app. Then when the view is loaded, you can start your animation. As a final result, you will have an "animated splash screen."

The sequence progresses like this:

App starts → display static launch screen → transition to entrance-VC, which won't be visible to the user because the scenes look the same → entrance-VC view is loaded as an animation.

In summary, treat your launch screen's .xib file as the first frame of your animated launch screen.


Launch screen is static and we cannot perform any operation on launch screen. So not possible to display animation on launch screen. but we can achieve this using one way. First show static launch screen and then load viewcontroller,on that viewcontroller we can show gif of that animation. And after animation loop completes then call home screen of the app. Please refer following url for reference. for achiving animation on splash screen


You can check the following links for this kind of animation :

https://github.com/okmr-d/App-Launching-like-Twitter

http://iosdevtips.co/post/88481653818/twitter-ios-app-bird-zoom-animation

https://github.com/callumboddy/CBZSplashView


In my case the animation was to rotate an image in the launchScreen, Video thumbnail
Animated Launch Screen on YouTube

Step 1: I created the launchScreen with UiImageViews as below, Static Launch Screen

Step 2: I again created same screen in my storyBoard, and also created a viewController file for the same view, where I will write logic for the animation. I have given the name as, 'AnimatedlaunchScreenViewController'. The code for the viewController is below,

class AnimatedlaunchScreenViewController: UIViewController {

@IBOutlet weak var limezTitleImageView: UIImageView!

@IBOutlet weak var limezRoratingImageViewOutlet: UIImageView!
var timer: Timer?
var timeCount: Int = 0
let animationSeconds: Int = 3
override func viewDidLoad() {
    super.viewDidLoad()
    setTimerAndAnimateLaunchScreen()
}

//MARK: Animating flash Screen
func setTimerAndAnimateLaunchScreen(){
    //Set Timer
    timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(checkForTimerAndRedirect), userInfo: nil, repeats: true)
    let rotation = CABasicAnimation(keyPath: "transform.rotation")
    rotation.fromValue = 0
    rotation.toValue = 2 * Double.pi
    rotation.duration = 1.1
    rotation.repeatCount = Float.infinity
    self.limezRoratingImageViewOutlet.layer.add(rotation, forKey: "Spin")
}

@objc func checkForTimerAndRedirect(){
    if timeCount == animationSeconds{
        //Redirect to LogIn or HomePage
        timer?.invalidate()
        timer = nil

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        let homeVC = storyboard.instantiateViewController(withIdentifier: "HomePageViewController") as! HomePageViewController
        //Below's navigationController is useful if u want NavigationController
        let navigationController = UINavigationController(rootViewController: homeVC)
        appDelegate.window!.rootViewController = homeVC
    }else{
        //Increment the counter
        timeCount += 1
    }
}

}

In the above I First I have created Outlets, Then I have made use of Timer() for the animation period. Once the animation time period is completed I have redirected to the Home ViewController.

On the HomeScreen I have just displayed Limez label, so don't worry by seeing the same label again.