Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BoardingPageViewController: UIPageViewController {
- override func viewDidLoad() {
- super.viewDidLoad()
- dataSource = self
- delegate = self
- setViewControllers([getStepOne()], direction: .forward, animated: false, completion: nil)
- }
- override var preferredStatusBarStyle: UIStatusBarStyle {
- return .lightContent
- }
- func getStepOne() -> BoardView1ViewController {
- return storyboard!.instantiateViewController(withIdentifier: "BoardView1") as! BoardView1ViewController
- }
- func getStepTwo() -> BoardView2ViewController {
- return storyboard!.instantiateViewController(withIdentifier: "BoardView2") as! BoardView2ViewController
- }
- func getStepThree() -> BoardView3ViewController {
- return storyboard!.instantiateViewController(withIdentifier: "BoardView3") as! BoardView3ViewController
- }
- func getStepFour() -> BoardView4ViewController {
- return storyboard!.instantiateViewController(withIdentifier: "BoardView4") as! BoardView4ViewController
- }
- func getStepFive() -> BoardView5ViewController {
- return storyboard!.instantiateViewController(withIdentifier: "BoardView5") as! BoardView5ViewController
- }
- }
- extension BoardingPageViewController : UIPageViewControllerDataSource {
- func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
- if viewController.isKind(of: BoardView5ViewController.self) {
- // 5 -> 4
- return getStepFour()
- } else if viewController.isKind(of: BoardView4ViewController.self) {
- // 4 -> 3
- return getStepThree()
- } else if viewController.isKind(of: BoardView3ViewController.self) {
- // 3 -> 2
- return getStepTwo()
- } else if viewController.isKind(of: BoardView2ViewController.self) {
- // 2 -> 1
- return getStepOne()
- } else {
- // 0 -> end of the road
- return nil
- }
- }
- func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
- if viewController.isKind(of: BoardView1ViewController.self) {
- // 0 -> 1
- return getStepTwo()
- } else if viewController.isKind(of: BoardView2ViewController.self) {
- // 1 -> 2
- return getStepThree()
- } else if viewController.isKind(of: BoardView3ViewController.self) {
- // 1 -> 2
- return getStepFour()
- } else if viewController.isKind(of: BoardView4ViewController.self) {
- // 1 -> 2
- return getStepFive()
- } else {
- // 2 -> end of the road
- return nil
- }
- }
- func presentationCount(for pageViewController: UIPageViewController) -> Int {
- return 5
- }
- func presentationIndex(for pageViewController: UIPageViewController) -> Int {
- return 0
- }
- }
- extension BoardingPageViewController : UIPageViewControllerDelegate {
- }
- override func viewDidAppear(_ animated: Bool) {
- chainAni = true
- ani0()
- }
- func ani0() {
- if chainAni != true {
- return
- }
- UIView.animate(withDuration: 1, delay: 1, animations: {
- self.handPic.alpha = 1
- }) { (false) in
- self.ani1()
- }
- }
- func ani1() {
- if chainAni != true {
- return
- }
- UIView.animate(withDuration: 1.5, delay: 1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
- self.highlightAction(any: self.handPic)
- self.highlightAction(any: self.folderBtn)
- }) { (false) in
- self.ani2()
- }
- }
- func ani2() {
- if chainAni != true {
- return
- }
- UIView.animate(withDuration: 1.5, delay: 1, animations: {
- self.unhighlightAction(any: self.handPic)
- self.unhighlightAction(any: self.folderBtn)
- }) { (false) in
- self.ani3()
- }
- }
- func ani3() {
- if chainAni != true {
- return
- }
- UIView.animate(withDuration: 0.5, delay: 0, animations: {
- self.handPic.alpha = 0
- self.alertImg.alpha = 1
- self.alertImg.transform = .identity
- }) { (false) in
- self.ani4()
- }
- }
- func clearAni() {
- alertImg.image = #imageLiteral(resourceName: "alert1")
- darkView.removeFromSuperview()
- screenView.removeFromSuperview()
- mainImg.alpha = 1
- alertImg.alpha = 0
- alert2Img.alpha = 0
- handPic.alpha = 0
- handPic.transform = .identity
- hand2Pic.alpha = 0
- hand2Pic.transform = .identity
- newFolderImg.alpha = 0
- newFolderImg.transform = .identity
- }
- override func viewDidDisappear(_ animated: Bool) {
- clearAni()
- chainAni = false
- }
- func clearAni() {
- alertImg.image = #imageLiteral(resourceName: "alert1")
- mainImg.layer.removeAllAnimations()
- mainLbl.layer.removeAllAnimations()
- alertImg.layer.removeAllAnimations()
- alert2Img.layer.removeAllAnimations()
- folderBtn.layer.removeAllAnimations()
- handPic.layer.removeAllAnimations()
- hand2Pic.layer.removeAllAnimations()
- darkView.layer.removeAllAnimations()
- mainImg.alpha = 1
- alertImg.alpha = 0
- alert2Img.alpha = 0
- handPic.alpha = 0
- handPic.transform = .identity
- hand2Pic.alpha = 0
- hand2Pic.transform = .identity
- newFolderImg.alpha = 0
- newFolderImg.transform = .identity
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement