Skip to content

Instantly share code, notes, and snippets.

@RustemAqtau
Created July 3, 2020 06:57
Show Gist options
  • Save RustemAqtau/a6bd9f207c4c43abe512ab6a7f816881 to your computer and use it in GitHub Desktop.
Save RustemAqtau/a6bd9f207c4c43abe512ab6a7f816881 to your computer and use it in GitHub Desktop.
MainTabBarController Swift
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