@@ -72,12 +72,19 @@ class UITabBarControllerImpl extends UITabBarController {
7272 public viewWillTransitionToSizeWithTransitionCoordinator ( size : CGSize , coordinator : UIViewControllerTransitionCoordinator ) : void {
7373 super . viewWillTransitionToSizeWithTransitionCoordinator ( size , coordinator ) ;
7474 UIViewControllerTransitionCoordinator . prototype . animateAlongsideTransitionCompletion
75- . call ( coordinator , null , ( ) => {
75+ . call ( coordinator , ( ) => {
7676 const owner = this . _owner . get ( ) ;
77- if ( owner && owner . items ) {
78- // owner.items.forEach(tabItem => tabItem._updateTitleAndIconPositions()); TODO:
77+ if ( owner && owner . tabStrip && owner . tabStrip . items ) {
78+ const tabStrip = owner . tabStrip ;
79+ tabStrip . items . forEach ( tabStripItem => {
80+ updateBackgroundPositions ( tabStrip , tabStripItem ) ;
81+
82+ const index = tabStripItem . _index ;
83+ const tabBarItemController = this . viewControllers [ index ] ;
84+ updateTitleAndIconPositions ( tabStripItem , tabBarItemController . tabBarItem , tabBarItemController ) ;
85+ } ) ;
7986 }
80- } ) ;
87+ } , null ) ;
8188 }
8289
8390 // Mind implementation for other controllers
@@ -213,6 +220,26 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
213220 }
214221}
215222
223+ function updateBackgroundPositions ( tabStrip : TabStrip , tabStripItem : TabStripItem ) {
224+ let bgView = ( < any > tabStripItem ) . bgView ;
225+ if ( ! bgView ) {
226+ const index = tabStripItem . _index ;
227+ const width = tabStrip . nativeView . frame . size . width / tabStrip . items . length ;
228+ const frame = CGRectMake ( width * index , 0 , width , tabStrip . nativeView . frame . size . width ) ;
229+ bgView = UIView . alloc ( ) . initWithFrame ( frame ) ;
230+ tabStrip . nativeView . insertSubviewAtIndex ( bgView , 0 ) ;
231+ ( < any > tabStripItem ) . bgView = bgView ;
232+ } else {
233+ const index = tabStripItem . _index ;
234+ const width = tabStrip . nativeView . frame . size . width / tabStrip . items . length ;
235+ const frame = CGRectMake ( width * index , 0 , width , tabStrip . nativeView . frame . size . width ) ;
236+ bgView . frame = frame ;
237+ }
238+
239+ const backgroundColor = tabStripItem . style . backgroundColor ;
240+ bgView . backgroundColor = backgroundColor instanceof Color ? backgroundColor . ios : backgroundColor ;
241+ }
242+
216243function updateTitleAndIconPositions ( tabStripItem : TabStripItem , tabBarItem : UITabBarItem , controller : UIViewController ) {
217244 if ( ! tabStripItem || ! tabBarItem ) {
218245 return ;
@@ -345,21 +372,11 @@ export class BottomNavigation extends TabNavigationBase {
345372 }
346373
347374 public setTabBarItemBackgroundColor ( tabStripItem : TabStripItem , value : UIColor | Color ) : void {
348- if ( ! this . tabStrip ) {
375+ if ( ! this . tabStrip || ! tabStripItem ) {
349376 return ;
350377 }
351378
352- let bgView = ( < any > tabStripItem ) . bgView ;
353- if ( ! bgView ) {
354- const index = ( < any > tabStripItem ) . index ;
355- const width = this . tabStrip . nativeView . frame . size . width / this . tabStrip . items . length ;
356- const frame = CGRectMake ( width * index , 0 , width , this . tabStrip . nativeView . frame . size . width ) ;
357- bgView = UIView . alloc ( ) . initWithFrame ( frame ) ;
358- this . tabStrip . nativeView . insertSubviewAtIndex ( bgView , 0 ) ;
359- ( < any > tabStripItem ) . bgView = bgView ;
360- }
361-
362- bgView . backgroundColor = value instanceof Color ? value . ios : value ;
379+ updateBackgroundPositions ( this . tabStrip , tabStripItem ) ;
363380 }
364381
365382 public setTabBarItemColor ( tabStripItem : TabStripItem , value : UIColor | Color ) : void {
@@ -509,7 +526,7 @@ export class BottomNavigation extends TabNavigationBase {
509526 applyStatesToItem ( tabBarItem , states ) ;
510527
511528 controller . tabBarItem = tabBarItem ;
512- ( < any > tabStripItem ) . index = i ;
529+ tabStripItem . _index = i ;
513530 tabStripItem . setNativeView ( tabBarItem ) ;
514531 }
515532
0 commit comments