ReactNative开发——StatusBar

ReactNative开发——StatusBar

StatusBar用来设置并动态改变设备的状态栏显示特性。

基本属性

 componentDidMount(){
        window.setTimeout(()=>{
            //获得状态栏高度;
            console.log('height:'+StatusBar.currentHeight)
        },1)
    }

    render() {
        return (

            <View style={{flex: 1, justifyContent: 'flex-start'}}>
                <StatusBar
                    hidden={false} //是否隐藏状态栏。
                    animated={true} //是否需要动画效果
                    translucent={false} //android平台,是否有半透明效果,如果为true,状态栏会浮在下面的布局上面,
                    backgroundColor={'red'} // android 平台,设置状态栏配背景颜色
                    barStyle={'default'} //可以取值 'default', 'light-content', 'dark-content'它的默认是default,
                />

            </View>
        );
    }
}
属性作用
animatedbool类型,指定状态栏的变化是否应以动画形式呈现。目前支持这几种样式:backgroundColor, barStyle和hidden。
hiddenbool类型,是否隐藏状态栏
backgroundColorandorid平台,状态栏的背景颜色
translucentbool 类型,android平台,指定是否为透明,设置为true,状态栏会浮下面的布局上面。
barStyle用来指定状态栏文本颜色,可以取值:’default’, ‘light-content’, ‘dark-content’
networkActivityIndicatorVisibleios,指定是否显示网络活动提示符。
showHideTransitionios,通过hidden属性来显示或隐藏状态栏时所使用的动画效果。默认值为’fade’。

获得高度

可以通过:StatusBar.currentHeight 获取

参考

http://reactnative.cn/docs/0.44/statusbar.html#content

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值