감사 VAR pageviewController = UIPageViewController()
pageviewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
pageviewController.view.frame = CGRect(x: 0, y: 0, width: 320 , height: 568)
pageviewController.setViewControllers([arrayControllers[0]], direction: .forward, animated: false, completion: nil)
addChildViewController(pageviewController)
viewToAdd.addSubview(pageviewController.view)
pageviewController.didMove(toParentViewController: self)
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeLeft.direction = UISwipeGestureRecognizerDirection.left
self.view.addGestureRecognizer(swipeLeft)
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.right:
//right view controller
print("Swipe Right")
case UISwipeGestureRecognizerDirection.left:
//left view controller
print("Swipe left")
default:
break
}
}
}
[XLPagerTabStrip] (https://github.com/xmartlabs/XLPagerTabStrip) 내가 비슷한 상황을 가진 사람에게 추천이를 돌봐로
이 목적을 위해 라이브러리를 사용하여 종료 –