从零开始RNReact NativeReact Native的魔盒

ReactNative之TabNavigator(十二)

2017-05-06  本文已影响6163人  袁峥

前言

眼看很多公司都开始尝试使用ReactNative,达到跨平台开发,最近也写了很多文章,希望让更多想了解的同学快速上手ReactNative.

如果喜欢我的文章,可以关注我微博:袁峥Seemygo

ReactNative之TabNavigator

TabNavigator常用属性

TabNavigator属性.png

iOS和安卓适配

TabNavigator.png

使用

npm install react-native-tab-navigator --save
import TabNavigator from 'react-native-tab-navigator';
render() {
        return (
            <TabNavigator>
                <TabNavigator.Item
                    title="消息"
                    selected={0==this.state.selectIndex}
                    renderIcon={() => <Image source={{uri:'tab_recent_nor'}} style={styles.iconStyle}/>}
                    onPress={() => this.setState({ selectIndex: 0 })}>
                    <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
                        <Text>消息</Text>
                    </View>
                </TabNavigator.Item>
                <TabNavigator.Item
                    title="联系人"
                    selected={1==this.state.selectIndex}
                    renderIcon={() => <Image source={{uri:'tab_recent_nor'}} style={styles.iconStyle}/>}
                    onPress={() => this.setState({ selectIndex: 1 })}>
                    <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
                        <Text>联系人</Text>
                    </View>
                </TabNavigator.Item>
                <TabNavigator.Item
                    title="动态"
                    selected={2==this.state.selectIndex}
                    renderIcon={() => <Image source={{uri:'tab_qworld_nor'}} style={styles.iconStyle}/>}
                    onPress={() => this.setState({ selectIndex: 2 })}>
                    <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
                        <Text>动态</Text>
                    </View>
                </TabNavigator.Item>
            </TabNavigator>
        )

    }

安卓加载图片

安卓图片路径.png
上一篇 下一篇

猜你喜欢

热点阅读