/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
TabBarIOS,
StatusBar,
} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
constructor(props){
super(props);
this.state={
selectedTab:"图书"
}
}
render() {
return (
<TabBarIOS>
<TabBarIOS.Item
title="图书"
//每次添加新图片都要重新run一下Xcode
//下面一行是ES5的写法在ES6中无法使用
// icon={require("image!book_16")}
//ES6中的写法为:icon={{uri:'imageName'}}
icon={{uri:'book_16'}}
selected={this.state.selectedTab==="图书"}
onPress={()=>{
this.setState({
selectedTab:"图书"
})
}}>
<View style={{backgroundColor:'green',flex:1}}></View>
</TabBarIOS.Item>
<TabBarIOS.Item
title="电影"
icon={{uri:'movie_16'}}
selected={this.state.selectedTab==="电影"}
onPress={()=>{
this.setState({
selectedTab:"电影"
})
}}>
<View style={{backgroundColor:'skyblue',flex:1}}></View>
</TabBarIOS.Item>
</TabBarIOS>
);
}
}
转载于:https://www.cnblogs.com/Jayeblog/p/8509384.html
相关资源:JAVA上百实例源码以及开源项目