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> ); } }
属性 | 作用 |
---|---|
获得高度
可以通过:StatusBar.currentHeight
获取