how to make a animated splash screen like below image in iOS 9.3.
If you want to customize it, you'll have access to the SplashScreenView and its icon and can run any animation on them, with settings for transform, opacity, and color. In that case, the splash screen needs to be manually removed when the animation is done.
storyboard to configure your launch screen. If your project doesn't contain a default launch screen file, add a launch screen file and set the launch screen file for the target in the project editor. Choose File > New > File. Under User Interface, select Launch Screen, and click Next.
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,
Animated Launch Screen on YouTube
Step 1: I created the launchScreen with UiImageViews as below,
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With