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

后端 未结 5 1306
旧时难觅i
旧时难觅i 2020-11-30 00:51

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

\"enter

相关标签:
5条回答
  • 2020-11-30 01:09

    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.

    0 讨论(0)
  • 2020-11-30 01:15

    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

    0 讨论(0)
  • 2020-11-30 01:17

    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

    0 讨论(0)
  • 2020-11-30 01:19

    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.

    0 讨论(0)
  • 2020-11-30 01:21

    You can not add animation in splash screen but you can produce same result by creating your view controller with following two option

    1. Add a gif image on view controller or
    2. Add a video in view controller

    Then when app launch, App static splash screen will show and navigate to custom view controller where animation will show either a gif or video. When video complete you will navigate to app landing screen.

    0 讨论(0)
提交回复
热议问题