TabBarIOS中icon的本地加載方式
阿新 • • 發佈:2018-03-05
highlight OS state brush usb itl from pro per
/** * 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> ); } }
TabBarIOS中icon的本地加載方式