$ npm install @react-native-community/status-bar --save
$ react-native link @react-native-community/status-bar
Libraries
â Add Files to [your project's name]
node_modules
â react-native-status-bar
and add RNCStatusBar.xcodeproj
libRNCStatusBar.a
to your project's Build Phases
â Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.reactnativecommunity.statusbar.RNCStatusBarPackage;
to the imports at the top of the filenew RNCStatusBarPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-status-bar'
project(':react-native-status-bar').projectDir = new File(rootProject.projectDir, '../../node_modules/@react-native-community/status-bar/android')
android/app/build.gradle
:
implementation project(':react-native-status-bar')
import StatusBar from '@react-native-community/status-bar'; function MyComponent() { return ( <TouchableHighlight style={styles.wrapper} onPress={() => StatusBar.setHidden(true, "slide");} // or "fade" > <View style={styles.button}> <Text> Hide status bar </Text> </View> </TouchableHighlight> ) }Api
For cases where using a component is not ideal, there is also an imperative API exposed as static functions on the component. It is however not recommended to use the static API and the component for the same prop because any value set by the static API will get overriden by the one set by the component in the next render.
ConstantscurrentHeight
(Android only) The height of the status bar.
animated
barStyle
hidden
backgroundColor
translucent
networkActivityIndicatorVisible
showHideTransition
animated
If the transition between status bar property changes should be animated. Supported for backgroundColor, barStyle and hidden.
barStyle
Sets the color of the status bar text.
Type Required enum('default', 'light-content', 'dark-content') Nohidden
If the status bar is hidden.
backgroundColor
The background color of the status bar.
Type Required Platform color No Androidtranslucent
If the status bar is translucent. When translucent is set to true, the app will draw under the status bar. This is useful when using a semi transparent status bar color.
Type Required Platform bool No AndroidnetworkActivityIndicatorVisible
If the network activity indicator should be visible.
Type Required Platform bool No iOSshowHideTransition
The transition effect when showing and hiding the status bar using the hidden
prop. Defaults to 'fade'.
setHidden()
static setHidden(hidden: boolean, [animation]: StatusBarAnimation)
Show or hide the status bar
Parameters:
Name Type Required Description hidden boolean Yes Hide the status bar. animation StatusBarAnimation No Optional animation when changing the status bar hidden property.setBarStyle()
static setBarStyle(style: StatusBarStyle, [animated]: boolean)
Set the status bar style
Parameters:
Name Type Required Description style [StatusBarStyle]( #statusbarstyle) Yes Status bar style to set animated boolean No Animate the style change.setNetworkActivityIndicatorVisible()
static setNetworkActivityIndicatorVisible(visible: boolean)
Control the visibility of the network activity indicator
Parameters:
Name Type Required Description visible boolean Yes Show the indicator.setBackgroundColor()
static setBackgroundColor(color: string, [animated]: boolean)
Set the background color for the status bar
Parameters:
Name Type Required Description color color Yes Background color. animated boolean No Animate the style change.setTranslucent()
static setTranslucent(translucent: boolean)
Control the translucency of the status bar
Parameters:
Name Type Required Description translucent boolean Yes Set as translucent. Type Definitions StatusBarStyleStatus bar style
Constants:
Value Description default Default status bar style (dark for iOS, light for Android) light-content Dark background, white texts and icons dark-content Light background, dark texts and icons (requires API>=23 on Android) StatusBarAnimationStatus bar animation
Constants:
Value Description none No animation fade Fade animation slide Slide animationRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4