Is it possible to create a custom tabBarController
class in swift to animate programmatic and interactive transitions between tabs?
Asked
Active
Viewed 4,525 times
5

Ashish Kakkad
- 23,586
- 12
- 103
- 136

Isaac Wasserman
- 1,461
- 4
- 19
- 39
-
Which kind of transitions do you have in mind? – qwerty_so May 17 '15 at 17:18
-
Just like a normal sugue – Isaac Wasserman May 17 '15 at 17:21
-
I can't help much on iOS (just on OSX). It was just a question that came to mind when I reviewed your question. You need to wait for someone else to chip in. – qwerty_so May 17 '15 at 18:02
2 Answers
1
You can try this for transition animation on tabbar selecetion
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
guard let fromView = selectedViewController?.view, let toView = viewController.view else {
return false
}
UIView.transition(from: fromView, to: toView, duration: 0.3, options: [.transitionCrossDissolve], completion: nil)
return true }
for reference use this link
How to animate Tab bar tab switch with a CrossDissolve slide transition?

Sazid Iqabal
- 409
- 2
- 21
-
1This doesn't work when programatically calling .setSelectedIndex, however it does work when tapping tabs on the tab bar controller. Is there any way to improve your answer so that it will work for the method call mentioned? – TheJeff Jul 19 '19 at 15:45
1
I just figured this out, and posted an answer on another thread (link below). It adds a method:
tabBarController.setSelectedWithIndex(1)
to get this done with an animation.
I hope it works for you!

TheJeff
- 3,665
- 34
- 52