我希望可以幫助您與下面的代碼:
func application(_application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = LongUITabBarController()
window?.makeKeyAndVisible()
return true
}
import UIKit
class LongUITabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let vc1 = VC1_ViewController()
let vc2 = VC2_ViewController()
let vc3 = VC3_ViewController()
let vc4 = VC4_ViewController()
vc1.tabBarItem = UITabBarItem(title: "LIST ALL", image: UIImage(named: "list"), tag: 1)
vc2.tabBarItem = UITabBarItem(title: "BEST CELLER", image: UIImage(named: "bestCeller"), tag: 2)
vc3.tabBarItem = UITabBarItem(title: "MOST LIKE", image: UIImage(named: "like"), tag: 3)
vc4.tabBarItem = UITabBarItem(title: "NEW", image: UIImage(named: "new"), tag: 4)
viewControllers = [vc1, vc2, vc3, vc4]
setViewControllers(viewControllers, animated: true)
// backGround for tapBarView
tabBar.barTintColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)
}
}