classPageViewController:UIPageViewController{varcontrollers:[UIViewController]=[]overridefuncviewDidLoad(){super.viewDidLoad()// Do any additional setup after loading the view.view.backgroundColor=.blackletstb=storyboard!letpage1=stb.instantiateViewController(withIdentifier:"page1")letpage2=stb.instantiateViewController(withIdentifier:"page2")letpage3=stb.instantiateViewController(withIdentifier:"page3")controllers=[page1,page2,page3]setViewControllers([controllers[0]],direction:.forward,animated:true,completion:nil)dataSource=self}/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/}extensionPageViewController:UIPageViewControllerDataSource{funcpageViewController(_pageViewController:UIPageViewController,viewControllerBeforeviewController:UIViewController)->UIViewController?{ifletindex=controllers.firstIndex(of:viewController),index-1>=0{returncontrollers[index-1]}else{returnnil}}funcpageViewController(_pageViewController:UIPageViewController,viewControllerAfterviewController:UIViewController)->UIViewController?{ifletindex=controllers.firstIndex(of:viewController),index+1<controllers.count{returncontrollers[index+1]}else{returnnil}}funcpresentationCount(forpageViewController:UIPageViewController)->Int{returncontrollers.count}funcpresentationIndex(forpageViewController:UIPageViewController)->Int{return0}}
classViewController:UIViewController{overridefuncviewDidLoad(){super.viewDidLoad()// Do any additional setup after loading the view.}@IBActionfuncbuttonTapped(_sender:Any){letstb=UIStoryboard(name:"Walkthrough",bundle:nil)letpageVC=stb.instantiateViewController(withIdentifier:"walk")pageVC.modalPresentationStyle=.currentContextpresent(pageVC,animated:true,completion:nil)}}