TabBarIOS和 TabBarIOS.Item的使用

/**

import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TabBarIOS,
} from 'react-native';

export default class index extends Component {

constructor(props)
{
super(props);
this.state={
selectedTab: '1',
notifCount: 0,
presses: 0,
}
}

render() {
return (
<TabBarIOS tintColor="white" barTintColor="darkslateblue" >
<TabBarIOS.Item title="首頁(yè)" systemIcon="downloads"
selected={this.state.selectedTab === '1'}
onPress={()=>{
this.setState({
selectedTab: '1',
})

  }}>
      {/* <View style={[styles.commonViewStyle,{backgroundColor:'red'}]}>
                <Text>首頁(yè)</Text>
      </View> */}
      {this.createView('red','內(nèi)容','1')}
  </TabBarIOS.Item>

  <TabBarIOS.Item title="第二個(gè)頁(yè)面" systemIcon="contacts"
      selected={this.state.selectedTab === '2'}
      onPress={()=>{
    this.setState({
    selectedTab:'2',
  })
}} >
{/* <View style={[styles.commonViewStyle,{backgroundColor:'blue'}]}>
                <Text>2</Text>
</View> */}
{this.createView('yellow','內(nèi)容','2')}
  </TabBarIOS.Item>
  <TabBarIOS.Item title="第san個(gè)頁(yè)面" systemIcon="contacts"
    selected={this.state.selectedTab === '3'}
    onPress={  ()=>{
      this.setState({
       selectedTab: '3',
     });

  }}>
  {/* <View style={[styles.commonViewStyle,{backgroundColor:'blue'}]}>
                  <Text>3</Text>
  </View> */}
  {this.createView('blue','內(nèi)容','3')}
  </TabBarIOS.Item>
</TabBarIOS>
);

}

createView(color,pageText,num){
return(
<View style={[styles.commonViewStyle,{backgroundColor:color}]}>
<Text>{num}</Text>
</View>
);
}
}

const styles = StyleSheet.create({
tabContent:{
flex:1,
alignItems:'center'
},
tabText: {
color: 'white',
margin: 50,
},
container: {
flex: 1,
backgroundColor: '#F5FCFF',
},
commonViewStyle:{
flex:1,
justifyContent:'center',
alignItems:'center'
},
});

AppRegistry.registerComponent('RNProjectFrist', () => index);

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容