加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ReactNative开发——StatusBar

发布时间:2020-12-15 07:18:21 所属栏目:百科 来源:网络整理
导读:ReactNative开发——StatusBar StatusBar用来设置并动态改变设备的状态栏显示特性。 基本属性 componentDidMount(){ window.setTimeout(()={ //获得状态栏高度; console.log( 'height:' +StatusBar.currentHeight) }, 1 ) } render() { return ( View style

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

获得高度

可以通过:StatusBar.currentHeight 获取

参考

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读