React-Native StatusBar的简单使用

2017-08-01  本文已影响0人  煎包小混沌

本来应该是使用StatusBarIOS的,但是发现StatusBarIOS竟然报错了,只好使用StatusBar,没关系,两者的基本功能都是一样的。

结合NavigatorIOS使用的效果:
Untitled1.gif
StatusBar的主要属性:
使用方法:
<View style={{flex: 1, backgroundColor: '#ffaaff'}}>
                <StatusBar barStyle={"dark-content"}
                           networkActivityIndicatorVisible={true}
                           showHideTransition={'fade'}/>
            </View>
效果图代码:
import React, { Component } from 'react';
import {
    AppRegistry,
    View,
    NavigatorIOS,
    StatusBar
} from 'react-native';

export default class Navigator extends Component{
    render(){
        return(
                <NavigatorIOS ref="nav"
                              style={{flex: 1}}
                              initialRoute={{
                                  component: MianView,
                                  title: 'nnn',
                                  passProps: {},
                                  rightButtonTitle: 'NA1  ',
                                  onRightButtonPress: ()=>{
                                      this.refs.nav.push({
                                          component: Naview2,
                                          title: 'vvv',
                                          rightButtonTitle: 'NA2  ',
                                          onRightButtonPress: () => {
                                              this.refs.nav.push({
                                                  component: Naview3,
                                                  title: 'sss',
                                                  onLeftButtonPress: () => {
                                                      this.refs.nav.pop({

                                                      });
                                                  }
                                              })
                                          },
                                          onLeftButtonPress: () => {
                                              this.refs.nav.pop({

                                              });
                                          }
                                      })
                                  },
                                  onLeftButtonPress: () => {
                                      this.refs.nav.pop({

                                      });
                                  }
                              }}/>
        )
    }
}
class MianView extends Component{
    render(){
        return(
            <View style={{flex: 1, backgroundColor: '#ffaaff'}}>
                <StatusBar barStyle={"dark-content"}
                           networkActivityIndicatorVisible={true}
                           showHideTransition={'fade'}
                           animated={true}
                           translucent={true}/>
            </View>
        )
    }
}
class Naview2 extends Component{
    render(){
        return(
            <View style={{flex: 1, backgroundColor: '#aaaaff'}}>
                <StatusBar barStyle={"light-content"}
                           networkActivityIndicatorVisible={false}
                           showHideTransition={'slide'}/>
            </View>
        )
    }
}
class Naview3 extends Component{
    render(){
        return(
            <View style={{flex: 1, backgroundColor: '#ffaaaa'}}>
                <StatusBar hidden={true}/>
            </View>
        )
    }
}
AppRegistry.registerComponent('Navigator', ()=>Navigator);
上一篇下一篇

猜你喜欢

热点阅读