只要一个方法就够了,思路是launchScreen作为window的一个addsubview
demo地址:https://github.com/w11p3333/LaunchDemo
在LaunchScreen中将Storyboard ID设置为Launch
实现以下方法
private func launchAnimation()
{
let vc = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateViewControllerWithIdentifier("Launch")
let launchview = vc.view
let delegate = UIApplication.sharedApplication().delegate
let mainWindow = delegate?.window
mainWindow!!.addSubview(launchview)
UIView.animateWithDuration(1, delay: 0.5, options: UIViewAnimationOptions.BeginFromCurrentState, animations: {
launchview.alpha = 0.0
launchview.layer.transform = CATransform3DScale(CATransform3DIdentity, 1.5, 1.5, 1.0)
}) { (finished) in
launchview.removeFromSuperview()
}
}
注意:若是应用使用storyboard中加载的,需要在初始界面的viewcontroller的viewDidAppear方法中调用。
若是应用从代码中加载的,需要在AppDelegate中didFinishLaunchingWithOptions方法中调用
网友评论