在 Swift 中滑动一个 uiView,例如 Tab View Controller

Swipe a uiView in Swift like Tab View Controller

我想像在 SwiftUI 的选项卡视图控制器中使用的那样滑动 uiView,但是在使用情节提要时,如果我们使用选项卡视图控制器,整个屏幕都会被滑动,但我只能滑动一半屏幕并执行一些功能那里。我附上它的截图以便更好地理解:

我想要这种回复。使用按钮 添加新组 我正在添加一个新组,通过滑动我想查看我的辅助组。

 let viewsList : [UIViewController] = {
        
        let storyBoard = UIStoryboard(name: "Main", bundle: nil)
       
        let vc1 = storyBoard.instantiateViewController(withIdentifier: "FirstViewController")
        let vc2 = storyBoard.instantiateViewController(withIdentifier: "SecondViewController")
        let vc3 = storyBoard.instantiateViewController(withIdentifier: "ThirdViewController")
        
        return [vc1, vc2, vc3]
        
    }()
    

在viewDidLoad()中添加代码

override func viewDidLoad() {
        super.viewDidLoad()
        self.dataSource = self
        self.delegate = self
        
        if let firstvc = viewsList.first {
            self.setViewControllers([firstvc], direction: .forward, animated: true, completion: nil)
        }
        
    }

检测下一页或上一页。

        func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [AnyObject], transitionCompleted completed: Bool) {
      if completed {
        if previousIndex < currentIndex {   // forward
    
        }
        else if previousIndex > currentIndex {  // reverse
    
        }
      }
    }