Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwipeableTabBarController inside UINavigationController #35

Closed
thealzgit opened this issue Apr 5, 2018 · 2 comments
Closed

SwipeableTabBarController inside UINavigationController #35

thealzgit opened this issue Apr 5, 2018 · 2 comments
Labels

Comments

@thealzgit
Copy link

I just want to move between my tab, but i dont want to loose my title and nav bar controller. Is it is possible?

@marcosgriselli
Copy link
Owner

I think so, if you put the UITabBarController inside a UINavigationController you should be able to do that.

@marcosgriselli marcosgriselli changed the title How can i swipe between tabs but the same nav bar SwipeableTabBarController inside UINavigationController Apr 5, 2018
@marcosgriselli
Copy link
Owner

Definitely possible

tabcontroller_inside_navcontroller

Quick code sample in AppDelegate.swift

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: UIScreen.main.bounds)
        let tabBarController = TabBarController()
        
        let controller1 = UIViewController()
        controller1.view.backgroundColor = UIColor.blue
        controller1.title = "VC 1"
        let controller2 = UIViewController()
        controller2.view.backgroundColor = UIColor.red
        controller2.title = "VC 2"
        
        tabBarController.setViewControllers([controller1, controller2], animated: false)
        tabBarController.title = "TabBar Title"
        let navigation = UINavigationController(rootViewController: tabBarController)
        if #available(iOS 11.0, *) { navigation.navigationBar.prefersLargeTitles = true } 
        window?.rootViewController = navigation
        tabBarController.selectedViewController = controller1
        window?.makeKeyAndVisible()
        return true
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants