Created
July 3, 2020 06:57
-
-
Save RustemAqtau/a6bd9f207c4c43abe512ab6a7f816881 to your computer and use it in GitHub Desktop.
MainTabBarController Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class MainTabBarController: UITabBarController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
view.backgroundColor = .white | |
tabBar.tintColor = #colorLiteral(red: 1, green: 0, blue: 0.3776089847, alpha: 1) | |
viewControllers = [ | |
generateViewController(rootViewController: SearchViewController(), image: #imageLiteral(resourceName: "search"), title: "Search"), | |
generateViewController(rootViewController: ViewController(), image: #imageLiteral(resourceName: "library"), title: "Library") | |
] | |
} | |
private func generateViewController(rootViewController: UIViewController, image: UIImage, title: String) -> UIViewController { | |
let navigationVC = UINavigationController(rootViewController: rootViewController) | |
navigationVC.tabBarItem.image = image | |
navigationVC.tabBarItem.title = title | |
rootViewController.navigationItem.title = title | |
navigationVC.navigationBar.prefersLargeTitles = true | |
return navigationVC | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment