-
Notifications
You must be signed in to change notification settings - Fork 0
/
PTBSettings.swift
65 lines (52 loc) · 2.19 KB
/
PTBSettings.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
//
// PTBSettings.swift
// Landlord
//
// Created by Przemyslaw Blasiak on 15.01.2015.
// Copyright (c) 2015 bprzemyslaw. All rights reserved.
//
import UIKit
/// Key for interactive color.
public let PTBInteractiveColorKey: String! = "InteractiveColor"
/// Key for informative color.
public let PTBInformativeColorKey: String! = "InformativeColor"
/// Key for background color.
public let PTBBackgroundColorKey: String! = "BackgroundColor"
/// Singleton containing framework settings
public class PTBSettings: NSObject {
// MARK: Public
/// Sets a basic palette of colors used throughout the application.
public func setColorPalette(#interactiveColor: UIColor, informativeColor: UIColor, backgroundColor: UIColor) {
self.colorPalette[PTBInteractiveColorKey] = interactiveColor
self.colorPalette[PTBInformativeColorKey] = informativeColor
self.colorPalette[PTBBackgroundColorKey] = backgroundColor
// Global tint
UIApplication.sharedApplication().delegate?.window??.tintColor = interactiveColor
// Text caret
UITextField.appearance().tintColor = interactiveColor
UITextView.appearance().tintColor = interactiveColor
// Switch
UISwitch.appearance().onTintColor = interactiveColor
// Navigation bar
UINavigationBar.appearance().barTintColor = backgroundColor
UINavigationBar.appearance().titleTextAttributes = NSDictionary(object: informativeColor, forKey: NSForegroundColorAttributeName) as [NSObject : AnyObject]
// Tab bar
UITabBar.appearance().barTintColor = backgroundColor
}
/// Represents a palette of colors used throughout the application.
public var colorPalette: [String: UIColor] = [
PTBInteractiveColorKey: UIColor.blueColor(),
PTBInformativeColorKey: UIColor.blackColor(),
PTBBackgroundColorKey: UIColor.whiteColor()
]
// Singleton instance
public class var sharedInstance: PTBSettings {
struct Static {
static var instance: PTBSettings!
}
if Static.instance == nil {
Static.instance = PTBSettings()
}
return Static.instance
}
}