@@ -189,39 +189,38 @@ class RayWenderlichTutorialView: BaseView {
189
189
}
190
190
191
191
fileprivate func showActionViewFor( imageName: String , text: String ) -> UIView {
192
- let actionView = UIView ( frame: . zero)
193
- actionView. flex. alignItems ( . center) . width ( 50 ) . marginRight ( 20.0 )
194
-
195
- let actionButton = UIButton ( type: . custom)
196
- actionButton. setImage ( UIImage ( named: imageName) , for: . normal)
197
- actionButton. flex. padding ( 10 )
198
- actionView. addSubview ( actionButton)
192
+ let actionView = UIView ( )
199
193
200
- let actionLabel = showLabelFor ( text: text)
201
- actionView. addSubview ( actionLabel)
194
+ actionView. flex. alignItems ( . center) . width ( 50 ) . marginRight ( 20.0 ) . define { ( flex) in
195
+ let actionButton = UIButton ( type: . custom)
196
+ actionButton. setImage ( UIImage ( named: imageName) , for: . normal)
197
+ flex. addItem ( actionButton) . padding ( 10 )
198
+
199
+ let actionLabel = showLabelFor ( text: text)
200
+ flex. addItem ( actionLabel)
201
+ }
202
202
203
203
return actionView
204
204
}
205
205
206
206
fileprivate func showTabBarFor( text: String , selected: Bool ) -> UIView {
207
- let tabView = UIView ( frame: . zero)
208
- tabView. flex. alignItems ( . center) . marginRight ( 20 )
209
-
210
207
let tabLabelFont = selected ? UIFont . boldSystemFont ( ofSize: 14.0 ) : UIFont . systemFont ( ofSize: 14.0 )
211
208
212
209
#if swift(>=4)
213
- let fontSize = text. size ( withAttributes: [ NSAttributedStringKey . font: tabLabelFont] )
210
+ let labelSize = text. size ( withAttributes: [ NSAttributedStringKey . font: tabLabelFont] )
214
211
#else
215
- let fontSize = text. size ( attributes: [ NSFontAttributeName: tabLabelFont] )
212
+ let labelSize = text. size ( attributes: [ NSFontAttributeName: tabLabelFont] )
216
213
#endif
217
214
218
- let tabSelectionView = UIView ( frame: CGRect ( x: 0 , y: 0 , width: fontSize. width, height: 3 ) )
219
- tabSelectionView. flex. width ( fontSize. width) . marginBottom ( 5 )
220
- tabSelectionView. backgroundColor = selected ? . red : . clear
221
- tabView. addSubview ( tabSelectionView)
215
+ let tabView = UIView ( )
222
216
223
- let tabLabel = showLabelFor ( text: text, font: tabLabelFont)
224
- tabView. addSubview ( tabLabel)
217
+ tabView. flex. alignItems ( . center) . marginRight ( 20 ) . define { ( flex) in
218
+ let tabSelectionView = UIView ( )
219
+ flex. addItem ( tabSelectionView) . width ( labelSize. width) . height ( 3 ) . marginBottom ( 5 ) . backgroundColor ( selected ? . red : . clear)
220
+
221
+ let tabLabel = showLabelFor ( text: text, font: tabLabelFont)
222
+ flex. addItem ( tabLabel)
223
+ }
225
224
226
225
return tabView
227
226
}
0 commit comments