自定义启动屏幕的时间

时间:2016-06-15 19:37:32

标签: xcode swift launch

我正在使用Xcode 7.2和swift 2.我在发布故事板中添加了一个启动屏幕。但是,当我运行应用程序时,启动屏幕会很快消失。有什么方法可以自定义时间吗?

1 个答案:

答案 0 :(得分:0)

您可以创建一个全新的ViewController来显示如下的启动画面:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    self.generateRandomSplashScreen()
    self.performSelector("removeSplashScreen", withObject: nil, afterDelay: <Your delay in seconds>)
    self.otherViewControllerLoad()
    // the other view controller
    self.window.makeKeyAndVisible()
    return true
}

func generateRandomSplashScreen() {
    splashScreenViewController = SplashScreenController(nibName: "SplashScreenController", bundle: NSBundle.mainBundle())
    self.window.addSubview(self.splashScreenViewController.view!)
}

func removeSplashScreen() {
    splashScreenViewController.view!.removeFromSuperview()
    self.window.rootViewController = self.tabBarController

}