-
Notifications
You must be signed in to change notification settings - Fork 92
/
Contents.swift
54 lines (42 loc) · 1005 Bytes
/
Contents.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
//: Playground - noun: a place where people can play
import UIKit
// 代码整理
enum Theme{
case DayMode
case NightMode
}
class UI{
var fontColor: UIColor!
var backgroundColor: UIColor!
var themeMode: Theme = .DayMode{
didSet{
self.changeTheme(self.themeMode)
}
}
init(){
self.themeMode = .DayMode
self.changeTheme(self.themeMode)
}
init(themeMode: Theme){
self.themeMode = themeMode
self.changeTheme(themeMode)
}
func changeTheme( themeMode: Theme ){
switch(themeMode){
case .DayMode:
fontColor = UIColor.blackColor()
backgroundColor = UIColor.whiteColor()
case .NightMode:
fontColor = UIColor.whiteColor()
backgroundColor = UIColor.blackColor()
}
}
}
let ui = UI()
ui.themeMode
ui.fontColor
ui.backgroundColor
ui.themeMode = .NightMode
ui.themeMode
ui.fontColor
ui.backgroundColor