/
AppDelegate.swift
71 lines (46 loc) · 2.15 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
// PlistDemo
//
// Created by Gesen on 16/3/1.
// Copyright © 2016年 Gesen. All rights reserved.
//
import UIKit
import SwiftTheme
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// default: Red.plist
ThemeManager.setTheme(plistName: "Red", path: .mainBundle)
// status bar
UIApplication.shared.theme_setStatusBarStyle("UIStatusBarStyle", animated: true)
// navigation bar
let navigationBar = UINavigationBar.appearance()
navigationBar.theme_tintColor = "Global.barTextColor"
navigationBar.theme_barTintColor = "Global.barTintColor"
navigationBar.theme_titleTextAttributes = ThemeDictionaryPicker(keyPath: "Global.barTextColor") { value -> [NSAttributedString.Key : AnyObject]? in
guard let rgba = value as? String else {
return nil
}
let color = UIColor(rgba: rgba)
let shadow = NSShadow(); shadow.shadowOffset = CGSize.zero
let titleTextAttributes = [
NSAttributedString.Key.foregroundColor: color,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16),
NSAttributedString.Key.shadow: shadow
]
return titleTextAttributes
}
// tab bar
let tabBar = UITabBar.appearance()
tabBar.theme_tintColor = "Global.barTextColor"
tabBar.theme_barTintColor = "Global.barTintColor"
return true
}
func applicationWillResignActive(_ application: UIApplication) { }
func applicationDidEnterBackground(_ application: UIApplication) { }
func applicationWillEnterForeground(_ application: UIApplication) { }
func applicationDidBecomeActive(_ application: UIApplication) { }
func applicationWillTerminate(_ application: UIApplication) { }
}