@@ -37,50 +37,79 @@ class LaunchViewController: UIViewController {
37
37
return _imageView
38
38
} ( )
39
39
40
- private lazy var taglineLabel : UILabel = {
41
- let _label = UILabel ( )
42
- _label. font = UIFont . tvFontForTagline ( )
43
- _label. textColor = UIColor . tvTaglineColor ( )
44
- _label. text = " Tagline " . localizedString
45
- _label. textAlignment = . Center
46
- _label. numberOfLines = 0
47
- _label. alpha = 0
48
- return _label
40
+ private lazy var activityIndicator : UIActivityIndicatorView = {
41
+ let _indicator = UIActivityIndicatorView ( activityIndicatorStyle: . WhiteLarge)
42
+ _indicator. color = UIColor . Palette. GreyishBrown
43
+ _indicator. hidesWhenStopped = true
44
+ return _indicator
49
45
} ( )
50
46
51
- private var taglineConstraint : NSLayoutConstraint ?
47
+ private lazy var upperTaglineLabel : UILabel = {
48
+ let _upper = UILabel . taglineLabel ( )
49
+ _upper. text = " Upper tagline " . localizedString
50
+ return _upper
51
+ } ( )
52
+
53
+ private lazy var lowerTaglineLabel : UILabel = {
54
+ let _lower = UILabel . taglineLabel ( )
55
+ _lower. text = " Lower tagline " . localizedString
56
+ return _lower
57
+ } ( )
58
+
59
+ private var upperTaglineConstraint : NSLayoutConstraint ?
60
+ private var lowerTaglineConstraint : NSLayoutConstraint ?
52
61
53
62
// MARK: - UIViewController
54
63
55
64
override func loadView( ) {
56
65
super. loadView ( )
57
66
view. backgroundColor = UIColor . tvBackgroundColor ( )
58
67
view. addSubview ( loadingImageView)
59
- view. addSubview ( taglineLabel)
68
+ view. addSubview ( activityIndicator)
69
+ view. addSubview ( upperTaglineLabel)
70
+ view. addSubview ( lowerTaglineLabel)
60
71
61
72
loadingImageView. translatesAutoresizingMaskIntoConstraints = false
62
- taglineLabel. translatesAutoresizingMaskIntoConstraints = false
73
+ activityIndicator. translatesAutoresizingMaskIntoConstraints = false
74
+ upperTaglineLabel. translatesAutoresizingMaskIntoConstraints = false
75
+ lowerTaglineLabel. translatesAutoresizingMaskIntoConstraints = false
63
76
64
77
loadingImageView. centerXAnchor. constraintEqualToAnchor ( view. centerXAnchor) . active = true
65
- loadingImageView. centerYAnchor. constraintEqualToAnchor ( view. centerYAnchor, constant: - 45 ) . active = true
78
+ loadingImageView. bottomAnchor. constraintEqualToAnchor ( view. centerYAnchor, constant: 50 ) . active = true
79
+
80
+ activityIndicator. centerXAnchor. constraintEqualToAnchor ( view. centerXAnchor, constant: 5 ) . active = true
81
+ activityIndicator. topAnchor. constraintEqualToAnchor ( loadingImageView. bottomAnchor, constant: 60 ) . active = true
66
82
67
- taglineConstraint = taglineLabel. topAnchor. constraintEqualToAnchor ( loadingImageView. bottomAnchor, constant: 100 )
68
- taglineConstraint? . active = true
69
- taglineLabel. centerXAnchor. constraintEqualToAnchor ( view. centerXAnchor) . active = true
83
+ upperTaglineConstraint = upperTaglineLabel. topAnchor. constraintEqualToAnchor ( activityIndicator. bottomAnchor, constant: 100 )
84
+ upperTaglineConstraint? . active = true
85
+ upperTaglineLabel. centerXAnchor. constraintEqualToAnchor ( view. centerXAnchor) . active = true
86
+
87
+ lowerTaglineConstraint = lowerTaglineLabel. topAnchor. constraintEqualToAnchor ( upperTaglineLabel. bottomAnchor, constant: 100 )
88
+ lowerTaglineConstraint? . active = true
89
+ lowerTaglineLabel. centerXAnchor. constraintEqualToAnchor ( view. centerXAnchor) . active = true
70
90
}
71
91
72
92
override func viewDidLoad( ) {
73
93
super. viewDidLoad ( )
94
+ activityIndicator. startAnimating ( )
74
95
fetchCategories ( )
75
96
}
76
97
77
98
override func viewDidAppear( animated: Bool ) {
78
99
super. viewDidAppear ( animated)
79
- UIView . animateWithDuration ( 0.5 ) {
80
- self . taglineLabel. alpha = 1
81
- self . taglineConstraint? . constant = 50
82
- self . view. layoutIfNeeded ( )
83
- }
100
+
101
+ UIView . animateKeyframesWithDuration ( 0.9 , delay: 0 , options: [ ] , animations: {
102
+ UIView . addKeyframeWithRelativeStartTime ( 0 , relativeDuration: 0.6 ) {
103
+ self . upperTaglineLabel. alpha = 1
104
+ self . upperTaglineConstraint? . constant = 40
105
+ self . view. layoutIfNeeded ( )
106
+ }
107
+ UIView . addKeyframeWithRelativeStartTime ( 0.2 , relativeDuration: 0.7 ) {
108
+ self . lowerTaglineLabel. alpha = 1
109
+ self . lowerTaglineConstraint? . constant = 0
110
+ self . view. layoutIfNeeded ( )
111
+ }
112
+ } , completion: nil )
84
113
}
85
114
86
115
// MARK: - Private Methods
@@ -104,3 +133,21 @@ class LaunchViewController: UIViewController {
104
133
}
105
134
106
135
}
136
+
137
+
138
+ ////////////////////////////////////////////////////////////////////////////////
139
+
140
+
141
+ private extension UILabel {
142
+
143
+ private class func taglineLabel( ) -> UILabel {
144
+ let label = UILabel ( )
145
+ label. font = UIFont . tvFontForTagline ( )
146
+ label. textColor = UIColor . tvTaglineColor ( )
147
+ label. textAlignment = . Center
148
+ label. numberOfLines = 0
149
+ label. alpha = 0
150
+ return label
151
+ }
152
+
153
+ }
0 commit comments