forked from ChenYilong/CYLTabBarController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppDelegate.swift
71 lines (47 loc) · 2.64 KB
/
AppDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// AppDelegate.swift
//
// v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
// Copyright © 2018 https://github.com/ChenYilong . All rights reserved.
//
import UIKit
import CYLTabBarController
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,UITabBarControllerDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CYLPlusButtonSubclass.register()
let mainTabBarVc = MainTabBarController(viewControllers: self.viewControllers(), tabBarItemsAttributes: self.tabBarItemsAttributesForController())
self.window = UIWindow()
self.window?.frame = UIScreen.main.bounds
self.window?.rootViewController = mainTabBarVc
mainTabBarVc?.hideTabBadgeBackgroundSeparator();
self.window?.makeKeyAndVisible()
UITabBar.appearance().backgroundColor = UIColor.white
return true
}
func viewControllers() -> [UINavigationController]{
let home = UINavigationController(rootViewController: HomeViewController())
let connection = UINavigationController(rootViewController: ConnectionViewController())
let message = UINavigationController(rootViewController: MessageViewController())
let personal = UINavigationController(rootViewController: PersonalViewController())
let viewControllers = [home, connection, message, personal]
return viewControllers
}
func tabBarItemsAttributesForController() -> [[String : String]] {
let tabBarItemOne = [CYLTabBarItemTitle:"首页",
CYLTabBarItemImage:"home_normal",
CYLTabBarItemSelectedImage:"home_highlight"]
let tabBarItemTwo = [CYLTabBarItemTitle:"同城",
CYLTabBarItemImage:"mycity_normal",
CYLTabBarItemSelectedImage:"mycity_highlight"]
let tabBarItemThree = [CYLTabBarItemTitle:"消息",
CYLTabBarItemImage:"message_normal",
CYLTabBarItemSelectedImage:"message_highlight"]
let tabBarItemFour = [CYLTabBarItemTitle:"我的",
CYLTabBarItemImage:"account_normal",
CYLTabBarItemSelectedImage:"account_highlight"]
let tabBarItemsAttributes = [tabBarItemOne,tabBarItemTwo,tabBarItemThree,tabBarItemFour]
return tabBarItemsAttributes
}
}