@@ -399,21 +399,15 @@ export class BottomNavigation extends TabNavigationBase {
399
399
items . forEach ( ( item , i ) => {
400
400
const controller = this . getViewController ( item ) ;
401
401
402
- let icon = null ;
403
- let title = "" ;
404
-
405
402
if ( this . tabStrip && this . tabStrip . items && this . tabStrip . items [ i ] ) {
406
- const tabStripItem = < TabStripItem > this . tabStrip . items [ i ] ;
407
- icon = this . _getIcon ( tabStripItem . iconSource ) ;
408
- title = tabStripItem . title ;
409
-
410
- const tabBarItem = UITabBarItem . alloc ( ) . initWithTitleImageTag ( ( title || "" ) , icon , i ) ;
411
- updateTitleAndIconPositions ( tabStripItem , tabBarItem , controller ) ;
403
+ const item = < TabStripItem > this . tabStrip . items [ i ] ;
404
+ const tabBarItem = this . createTabBarItem ( item , i ) ;
405
+ updateTitleAndIconPositions ( item , tabBarItem , controller ) ;
412
406
413
407
applyStatesToItem ( tabBarItem , states ) ;
414
408
415
409
controller . tabBarItem = tabBarItem ;
416
- tabStripItem . setNativeView ( tabBarItem ) ;
410
+ item . setNativeView ( tabBarItem ) ;
417
411
}
418
412
419
413
controllers . addObject ( controller ) ;
@@ -426,6 +420,20 @@ export class BottomNavigation extends TabNavigationBase {
426
420
this . _ios . moreNavigationController . delegate = this . _moreNavigationControllerDelegate ;
427
421
}
428
422
423
+ private createTabBarItem ( item : TabStripItem , index : number ) : UITabBarItem {
424
+ let image : UIImage ;
425
+ let title : string ;
426
+
427
+ // Image and Label children of TabStripItem
428
+ // take priority over its `iconSource` and `title` properties
429
+ image = item . image ? this . _getIcon ( item . image . src ) : this . _getIcon ( item . iconSource ) ;
430
+ title = item . label ? item . label . text : item . title ;
431
+
432
+ const tabBarItem = UITabBarItem . alloc ( ) . initWithTitleImageTag ( title , image , index ) ;
433
+
434
+ return tabBarItem ;
435
+ }
436
+
429
437
private _getIconRenderingMode ( ) : UIImageRenderingMode {
430
438
return UIImageRenderingMode . AlwaysOriginal ;
431
439
}
@@ -523,4 +531,4 @@ function getTitleAttributesForStates(tabView: BottomNavigation): TabStates {
523
531
function applyStatesToItem ( item : UITabBarItem , states : TabStates ) {
524
532
item . setTitleTextAttributesForState ( states . normalState , UIControlState . Normal ) ;
525
533
item . setTitleTextAttributesForState ( states . selectedState , UIControlState . Selected ) ;
526
- }
534
+ }
0 commit comments