I'm very very new to swift, and xcode. I've recently have been trying to create a app for fun...
What I am trying to achieve : (App Launch Logo Animation that after app is loaded it will take you to the home storyboard). I recently took a look at this video. It sort of confused me because my home story board is not loading correctly.
I would have to guess this is happening because the Story Board, HomeViewController
is just loading a black screen? I want it to be loading my "Home Storyboard" that I made.
My Launch Setup :
My Home Setup (what I want it to load into) notice I did change the class :
Code For Launch / View Controller :
import UIKit
class ViewController: UIViewController {
private lazy var imageView: UIImageView = {
lazy var imageView = UIImageView(frame: CGRect(x: 0, y: 0,width:150,height:150))
imageView.image = UIImage(named: "RobloxStudio")
return imageView
}()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(imageView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
imageView.center = view.center
DispatchQueue.main.asyncAfter(deadline: .now()+0.5, execute: {
self.animate()
})
}
private func animate(){
UIView.animate(withDuration: 1, animations: {
let size = self.view.frame.size.width * 2
let diffX = size - self.view.frame.size.width
let diffY = self.view.frame.size.height - size
self.imageView.frame = CGRect(
x: -(diffX/2),
y: diffY/2,
width: size,
height: size
)
})
UIView.animate(withDuration: 1.5, animations: {
self.imageView.alpha = 0
}, completion: { done in
if done{
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
let viewController = HomeViewController()
viewController.modalTransitionStyle = .crossDissolve
viewController.modalPresentationStyle = .fullScreen
self.present(viewController, animated: true)
})
}
})
}
}
Code For HomeViewController :
import UIKit
class HomeViewController: UIViewController{
override func viewDidLoad(){
super.viewDidLoad()
}
}
Is there any simpler way to make a launch animation, and to make it load into my story board that already has the designs? Any tips?