@@ -42,6 +42,10 @@ export type TabBarProps = BaseComponentInjectedProps & ViewPropTypes & {
42
42
* custom style for the selected indicator
43
43
*/
44
44
indicatorStyle ?: ViewStyle ,
45
+ /**
46
+ * The background color
47
+ */
48
+ backgroundColor : string ,
45
49
/**
46
50
* Tab Bar height
47
51
*/
@@ -77,7 +81,8 @@ class TabBar extends Component<TabBarProps, State> {
77
81
static displayName = 'TabBar' ;
78
82
79
83
static defaultProps = {
80
- selectedIndex : 0
84
+ selectedIndex : 0 ,
85
+ backgroundColor : DEFAULT_BACKGROUND_COLOR
81
86
} ;
82
87
83
88
static Item : typeof TabBarItem ;
@@ -92,7 +97,7 @@ class TabBar extends Component<TabBarProps, State> {
92
97
} ;
93
98
}
94
99
95
- styles = createStyles ( ) ;
100
+ styles = createStyles ( this . props ) ;
96
101
scrollContainerWidth : number = Constants . screenWidth ;
97
102
scrollContentWidth = 0 ;
98
103
contentOffset : any = { x : 0 , y : 0 } ;
@@ -247,7 +252,7 @@ class TabBar extends Component<TabBarProps, State> {
247
252
}
248
253
249
254
renderTabBar ( ) {
250
- const { height} = this . props ;
255
+ const { height, backgroundColor } = this . props ;
251
256
const { scrollEnabled} = this . state ;
252
257
const containerHeight = height || DEFAULT_HEIGHT ;
253
258
@@ -268,7 +273,7 @@ class TabBar extends Component<TabBarProps, State> {
268
273
{ this . renderChildren ( ) }
269
274
</ View >
270
275
</ ScrollView >
271
- { this . renderGradient ( containerHeight , DEFAULT_BACKGROUND_COLOR ) }
276
+ { this . renderGradient ( containerHeight , backgroundColor ) }
272
277
</ View >
273
278
) ;
274
279
}
@@ -312,7 +317,7 @@ class TabBar extends Component<TabBarProps, State> {
312
317
}
313
318
}
314
319
315
- function createStyles ( ) {
320
+ function createStyles ( { backgroundColor = DEFAULT_BACKGROUND_COLOR } ) {
316
321
return StyleSheet . create ( {
317
322
container : {
318
323
zIndex : 100
@@ -334,7 +339,7 @@ function createStyles() {
334
339
tabBar : {
335
340
flex : 1 ,
336
341
height : DEFAULT_HEIGHT ,
337
- backgroundColor : DEFAULT_BACKGROUND_COLOR
342
+ backgroundColor
338
343
} ,
339
344
shadowImage : {
340
345
width : '100%'
0 commit comments