![here is my UI for reference](https://i.stack.imgur.com/44HVt.png)
Я создаю пролистываемые вкладки с использованием контейнера. У меня есть три вкладки. Теперь проблема заключается в использовании жеста прокрутки. У меня есть только перетаскивание вправо и вправо, так как управлять тремя вкладкамис помощью пролистывания
я пробовал с помощью жеста смахивания, и для двух вкладок его навигация отлично, но как обработать третью вкладку с проведением влево вправо, позвольте мне показать вам, что я пробовал
Код
@objc func respondToSwipeGesture(_ sender: UIGestureRecognizer) {
if let swipeGesture = sender as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizer.Direction.right:
UIView.animate(withDuration: 0.3) {
self.viewLineOverDue.center = self.viewLineOverCenter
self.viewLineTodays.center = self.viewLineOverDue.center
self.viewFutureLine.center = self.viewLineOverDue.center
self.lblOverDue.textColor = UIColor(red: 218/255, green: 55/255, blue: 79/255, alpha: 1)
self.lblFuture.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
self.lblTodays.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
self.viewCOnOverdue.isHidden = false
self.viewCOnFuture.isHidden = true
self.viewConTodays.isHidden = true
}
print("right swipe")
case UISwipeGestureRecognizer.Direction.left:
print("leftSwipe")
UIView.animate(withDuration: 0.3) {
self.viewLineTodays.center = self.viewLineTodaysCenter
self.viewLineOverDue.center = self.viewLineTodays.center
self.viewFutureLine.center = self.viewLineTodays.center
self.lblTodays.textColor = UIColor(red: 218/255, green: 55/255, blue: 79/255, alpha: 1)
self.lblFuture.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
self.lblOverDue.textColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
self.viewCOnOverdue.isHidden = true
self.viewCOnFuture.isHidden = true
self.viewConTodays.isHidden = false
}
default:
break
}
}
}
в viewDidLoad ()
let swipeGestureLeft = UISwipeGestureRecognizer(target: self, action: #selector(CustomTabbarViewController.respondToSwipeGesture(_:)))
swipeGestureLeft.direction = UISwipeGestureRecognizer.Direction.left
self.view.addGestureRecognizer(swipeGestureLeft)
let swipeGestureRight = UISwipeGestureRecognizer(target: self, action:#selector(CustomTabbarViewController.respondToSwipeGesture(_:)) )
swipeGestureRight.direction = UISwipeGestureRecognizer.Direction.right
self.view .addGestureRecognizer(swipeGestureRight)
я присоединяю мой пользовательский интерфейс, чтобы вы могли легко понять
, поэтому мое требование состоит в том, что я хочу провеститри вкладки с использованием жеста смахивания
, как показано на снимке экрана. Я хочу перемещаться между вкладками друг с другом с помощью смахивания для двух вкладок, все работает нормально, как и мой код, но как управлять 3 вкладками